@cyberyozh/text-editor 0.5.0 → 0.5.2
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.d.mts +2 -2
- package/dist/editor.d.ts +2 -2
- package/dist/editor.js +125 -211
- package/dist/editor.js.map +1 -1
- package/dist/editor.mjs +118 -204
- package/dist/editor.mjs.map +1 -1
- package/dist/render.js +128 -220
- package/dist/render.js.map +1 -1
- package/dist/render.mjs +108 -200
- package/dist/render.mjs.map +1 -1
- package/package.json +35 -34
- package/src/editor/commands/items.ts +1 -6
- package/src/editor/handlers/insertion-handlers.test.ts +37 -0
- package/src/editor/handlers/insertion-handlers.ts +14 -9
- package/src/editor/handlers/markup-insertion.ts +9 -0
- package/src/extensions/base/compatibility.ts +3 -1
- package/src/extensions/base/myth-reality.ts +0 -1
package/dist/editor.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react from 'react';
|
|
2
2
|
import { JSONContent } from '@tiptap/react';
|
|
3
3
|
export { JSONContent } from '@tiptap/react';
|
|
4
4
|
import { JSONContent as JSONContent$1 } from '@tiptap/core';
|
|
@@ -61,7 +61,7 @@ interface KatexDialogContextProps {
|
|
|
61
61
|
latex?: string;
|
|
62
62
|
pos?: number;
|
|
63
63
|
}
|
|
64
|
-
declare const Tiptap: (props: TiptapProps) =>
|
|
64
|
+
declare const Tiptap: (props: TiptapProps) => react.JSX.Element;
|
|
65
65
|
|
|
66
66
|
interface SharedExtensionsOptions {
|
|
67
67
|
/**
|
package/dist/editor.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react from 'react';
|
|
2
2
|
import { JSONContent } from '@tiptap/react';
|
|
3
3
|
export { JSONContent } from '@tiptap/react';
|
|
4
4
|
import { JSONContent as JSONContent$1 } from '@tiptap/core';
|
|
@@ -61,7 +61,7 @@ interface KatexDialogContextProps {
|
|
|
61
61
|
latex?: string;
|
|
62
62
|
pos?: number;
|
|
63
63
|
}
|
|
64
|
-
declare const Tiptap: (props: TiptapProps) =>
|
|
64
|
+
declare const Tiptap: (props: TiptapProps) => react.JSX.Element;
|
|
65
65
|
|
|
66
66
|
interface SharedExtensionsOptions {
|
|
67
67
|
/**
|
package/dist/editor.js
CHANGED
|
@@ -5078,7 +5078,9 @@ var BaseLegacyFigure = import_extension_image2.default.extend({
|
|
|
5078
5078
|
isolating: true,
|
|
5079
5079
|
selectable: false,
|
|
5080
5080
|
addOptions() {
|
|
5081
|
+
const parentOptions = this.parent?.() || {};
|
|
5081
5082
|
return {
|
|
5083
|
+
...parentOptions,
|
|
5082
5084
|
HTMLAttributes: {},
|
|
5083
5085
|
getImageById: void 0
|
|
5084
5086
|
};
|
|
@@ -6144,39 +6146,24 @@ var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"
|
|
|
6144
6146
|
|
|
6145
6147
|
// node_modules/@tiptap/extension-text-style/dist/index.js
|
|
6146
6148
|
var import_core11 = require("@tiptap/core");
|
|
6147
|
-
var import_core12 = require("@tiptap/core");
|
|
6148
|
-
var import_core13 = require("@tiptap/core");
|
|
6149
|
-
var import_core14 = require("@tiptap/core");
|
|
6150
|
-
var import_core15 = require("@tiptap/core");
|
|
6151
|
-
var import_core16 = require("@tiptap/core");
|
|
6152
|
-
var import_core17 = require("@tiptap/core");
|
|
6153
6149
|
var MAX_FIND_CHILD_SPAN_DEPTH = 20;
|
|
6154
6150
|
var findChildSpans = (element, depth = 0) => {
|
|
6155
6151
|
const childSpans = [];
|
|
6156
|
-
if (!element.children.length || depth > MAX_FIND_CHILD_SPAN_DEPTH)
|
|
6157
|
-
return childSpans;
|
|
6158
|
-
}
|
|
6152
|
+
if (!element.children.length || depth > MAX_FIND_CHILD_SPAN_DEPTH) return childSpans;
|
|
6159
6153
|
Array.from(element.children).forEach((child) => {
|
|
6160
|
-
if (child.tagName === "SPAN")
|
|
6161
|
-
|
|
6162
|
-
} else if (child.children.length) {
|
|
6163
|
-
childSpans.push(...findChildSpans(child, depth + 1));
|
|
6164
|
-
}
|
|
6154
|
+
if (child.tagName === "SPAN") childSpans.push(child);
|
|
6155
|
+
else if (child.children.length) childSpans.push(...findChildSpans(child, depth + 1));
|
|
6165
6156
|
});
|
|
6166
6157
|
return childSpans;
|
|
6167
6158
|
};
|
|
6168
6159
|
var mergeNestedSpanStyles = (element) => {
|
|
6169
|
-
if (!element.children.length)
|
|
6170
|
-
return;
|
|
6171
|
-
}
|
|
6160
|
+
if (!element.children.length) return;
|
|
6172
6161
|
const childSpans = findChildSpans(element);
|
|
6173
|
-
if (!childSpans)
|
|
6174
|
-
return;
|
|
6175
|
-
}
|
|
6162
|
+
if (!childSpans) return;
|
|
6176
6163
|
childSpans.forEach((childSpan) => {
|
|
6177
|
-
var
|
|
6164
|
+
var _childSpan$parentElem;
|
|
6178
6165
|
const childStyle = childSpan.getAttribute("style");
|
|
6179
|
-
const closestParentSpanStyleOfChild = (
|
|
6166
|
+
const closestParentSpanStyleOfChild = (_childSpan$parentElem = childSpan.parentElement) === null || _childSpan$parentElem === void 0 || (_childSpan$parentElem = _childSpan$parentElem.closest("span")) === null || _childSpan$parentElem === void 0 ? void 0 : _childSpan$parentElem.getAttribute("style");
|
|
6180
6167
|
childSpan.setAttribute("style", `${closestParentSpanStyleOfChild};${childStyle}`);
|
|
6181
6168
|
});
|
|
6182
6169
|
};
|
|
@@ -6190,25 +6177,22 @@ var TextStyle = import_core11.Mark.create({
|
|
|
6190
6177
|
};
|
|
6191
6178
|
},
|
|
6192
6179
|
parseHTML() {
|
|
6193
|
-
return [
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
return false;
|
|
6201
|
-
}
|
|
6202
|
-
if (this.options.mergeNestedSpanStyles) {
|
|
6203
|
-
mergeNestedSpanStyles(element);
|
|
6204
|
-
}
|
|
6205
|
-
return {};
|
|
6206
|
-
}
|
|
6180
|
+
return [{
|
|
6181
|
+
tag: "span",
|
|
6182
|
+
consuming: false,
|
|
6183
|
+
getAttrs: (element) => {
|
|
6184
|
+
if (!element.hasAttribute("style")) return false;
|
|
6185
|
+
if (this.options.mergeNestedSpanStyles) mergeNestedSpanStyles(element);
|
|
6186
|
+
return {};
|
|
6207
6187
|
}
|
|
6208
|
-
];
|
|
6188
|
+
}];
|
|
6209
6189
|
},
|
|
6210
6190
|
renderHTML({ HTMLAttributes }) {
|
|
6211
|
-
return [
|
|
6191
|
+
return [
|
|
6192
|
+
"span",
|
|
6193
|
+
(0, import_core11.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),
|
|
6194
|
+
0
|
|
6195
|
+
];
|
|
6212
6196
|
},
|
|
6213
6197
|
addCommands() {
|
|
6214
6198
|
return {
|
|
@@ -6218,49 +6202,35 @@ var TextStyle = import_core11.Mark.create({
|
|
|
6218
6202
|
removeEmptyTextStyle: () => ({ tr: tr2 }) => {
|
|
6219
6203
|
const { selection } = tr2;
|
|
6220
6204
|
tr2.doc.nodesBetween(selection.from, selection.to, (node, pos) => {
|
|
6221
|
-
if (node.
|
|
6222
|
-
|
|
6223
|
-
}
|
|
6224
|
-
if (!node.marks.filter((mark) => mark.type === this.type).some((mark) => Object.values(mark.attrs).some((value) => !!value))) {
|
|
6225
|
-
tr2.removeMark(pos, pos + node.nodeSize, this.type);
|
|
6226
|
-
}
|
|
6205
|
+
if (!node.isInline) return true;
|
|
6206
|
+
if (!node.marks.filter((mark) => mark.type === this.type).some((mark) => Object.values(mark.attrs).some((value) => !!value))) tr2.removeMark(pos, pos + node.nodeSize, this.type);
|
|
6227
6207
|
});
|
|
6228
6208
|
return true;
|
|
6229
6209
|
}
|
|
6230
6210
|
};
|
|
6231
6211
|
}
|
|
6232
6212
|
});
|
|
6233
|
-
var BackgroundColor =
|
|
6213
|
+
var BackgroundColor = import_core11.Extension.create({
|
|
6234
6214
|
name: "backgroundColor",
|
|
6235
6215
|
addOptions() {
|
|
6236
|
-
return {
|
|
6237
|
-
types: ["textStyle"]
|
|
6238
|
-
};
|
|
6216
|
+
return { types: ["textStyle"] };
|
|
6239
6217
|
},
|
|
6240
6218
|
addGlobalAttributes() {
|
|
6241
|
-
return [
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
if (!attributes.backgroundColor) {
|
|
6254
|
-
return {};
|
|
6255
|
-
}
|
|
6256
|
-
return {
|
|
6257
|
-
style: `background-color: ${attributes.backgroundColor}`
|
|
6258
|
-
};
|
|
6259
|
-
}
|
|
6260
|
-
}
|
|
6219
|
+
return [{
|
|
6220
|
+
types: this.options.types,
|
|
6221
|
+
attributes: { backgroundColor: {
|
|
6222
|
+
default: null,
|
|
6223
|
+
parseHTML: (element) => {
|
|
6224
|
+
var _getStyleProperty;
|
|
6225
|
+
const value = (_getStyleProperty = (0, import_core11.getStyleProperty)(element, "background-color")) !== null && _getStyleProperty !== void 0 ? _getStyleProperty : element.style.backgroundColor;
|
|
6226
|
+
return value === null || value === void 0 ? void 0 : value.replace(/['"]+/g, "");
|
|
6227
|
+
},
|
|
6228
|
+
renderHTML: (attributes) => {
|
|
6229
|
+
if (!attributes.backgroundColor) return {};
|
|
6230
|
+
return { style: `background-color: ${attributes.backgroundColor}` };
|
|
6261
6231
|
}
|
|
6262
|
-
}
|
|
6263
|
-
];
|
|
6232
|
+
} }
|
|
6233
|
+
}];
|
|
6264
6234
|
},
|
|
6265
6235
|
addCommands() {
|
|
6266
6236
|
return {
|
|
@@ -6273,37 +6243,27 @@ var BackgroundColor = import_core12.Extension.create({
|
|
|
6273
6243
|
};
|
|
6274
6244
|
}
|
|
6275
6245
|
});
|
|
6276
|
-
var Color =
|
|
6246
|
+
var Color = import_core11.Extension.create({
|
|
6277
6247
|
name: "color",
|
|
6278
6248
|
addOptions() {
|
|
6279
|
-
return {
|
|
6280
|
-
types: ["textStyle"]
|
|
6281
|
-
};
|
|
6249
|
+
return { types: ["textStyle"] };
|
|
6282
6250
|
},
|
|
6283
6251
|
addGlobalAttributes() {
|
|
6284
|
-
return [
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
if (!attributes.color) {
|
|
6297
|
-
return {};
|
|
6298
|
-
}
|
|
6299
|
-
return {
|
|
6300
|
-
style: `color: ${attributes.color}`
|
|
6301
|
-
};
|
|
6302
|
-
}
|
|
6303
|
-
}
|
|
6252
|
+
return [{
|
|
6253
|
+
types: this.options.types,
|
|
6254
|
+
attributes: { color: {
|
|
6255
|
+
default: null,
|
|
6256
|
+
parseHTML: (element) => {
|
|
6257
|
+
var _getStyleProperty;
|
|
6258
|
+
const value = (_getStyleProperty = (0, import_core11.getStyleProperty)(element, "color")) !== null && _getStyleProperty !== void 0 ? _getStyleProperty : element.style.color;
|
|
6259
|
+
return value === null || value === void 0 ? void 0 : value.replace(/['"]+/g, "");
|
|
6260
|
+
},
|
|
6261
|
+
renderHTML: (attributes) => {
|
|
6262
|
+
if (!attributes.color) return {};
|
|
6263
|
+
return { style: `color: ${attributes.color}` };
|
|
6304
6264
|
}
|
|
6305
|
-
}
|
|
6306
|
-
];
|
|
6265
|
+
} }
|
|
6266
|
+
}];
|
|
6307
6267
|
},
|
|
6308
6268
|
addCommands() {
|
|
6309
6269
|
return {
|
|
@@ -6316,40 +6276,26 @@ var Color = import_core13.Extension.create({
|
|
|
6316
6276
|
};
|
|
6317
6277
|
}
|
|
6318
6278
|
});
|
|
6319
|
-
var FontFamily =
|
|
6279
|
+
var FontFamily = import_core11.Extension.create({
|
|
6320
6280
|
name: "fontFamily",
|
|
6321
6281
|
addOptions() {
|
|
6322
|
-
return {
|
|
6323
|
-
types: ["textStyle"]
|
|
6324
|
-
};
|
|
6282
|
+
return { types: ["textStyle"] };
|
|
6325
6283
|
},
|
|
6326
6284
|
addGlobalAttributes() {
|
|
6327
|
-
return [
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
var _a;
|
|
6339
|
-
return (_a = (0, import_core14.getStyleProperty)(element, "font-family")) != null ? _a : element.style.fontFamily;
|
|
6340
|
-
},
|
|
6341
|
-
renderHTML: (attributes) => {
|
|
6342
|
-
if (!attributes.fontFamily) {
|
|
6343
|
-
return {};
|
|
6344
|
-
}
|
|
6345
|
-
return {
|
|
6346
|
-
style: `font-family: ${attributes.fontFamily}`
|
|
6347
|
-
};
|
|
6348
|
-
}
|
|
6349
|
-
}
|
|
6285
|
+
return [{
|
|
6286
|
+
types: this.options.types,
|
|
6287
|
+
attributes: { fontFamily: {
|
|
6288
|
+
default: null,
|
|
6289
|
+
parseHTML: (element) => {
|
|
6290
|
+
var _getStyleProperty;
|
|
6291
|
+
return (_getStyleProperty = (0, import_core11.getStyleProperty)(element, "font-family")) !== null && _getStyleProperty !== void 0 ? _getStyleProperty : element.style.fontFamily;
|
|
6292
|
+
},
|
|
6293
|
+
renderHTML: (attributes) => {
|
|
6294
|
+
if (!attributes.fontFamily) return {};
|
|
6295
|
+
return { style: `font-family: ${attributes.fontFamily}` };
|
|
6350
6296
|
}
|
|
6351
|
-
}
|
|
6352
|
-
];
|
|
6297
|
+
} }
|
|
6298
|
+
}];
|
|
6353
6299
|
},
|
|
6354
6300
|
addCommands() {
|
|
6355
6301
|
return {
|
|
@@ -6362,39 +6308,26 @@ var FontFamily = import_core14.Extension.create({
|
|
|
6362
6308
|
};
|
|
6363
6309
|
}
|
|
6364
6310
|
});
|
|
6365
|
-
var FontSize =
|
|
6311
|
+
var FontSize = import_core11.Extension.create({
|
|
6366
6312
|
name: "fontSize",
|
|
6367
6313
|
addOptions() {
|
|
6368
|
-
return {
|
|
6369
|
-
types: ["textStyle"]
|
|
6370
|
-
};
|
|
6314
|
+
return { types: ["textStyle"] };
|
|
6371
6315
|
},
|
|
6372
6316
|
addGlobalAttributes() {
|
|
6373
|
-
return [
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
return (_a = (0, import_core15.getStyleProperty)(element, "font-size")) != null ? _a : element.style.fontSize;
|
|
6385
|
-
},
|
|
6386
|
-
renderHTML: (attributes) => {
|
|
6387
|
-
if (!attributes.fontSize) {
|
|
6388
|
-
return {};
|
|
6389
|
-
}
|
|
6390
|
-
return {
|
|
6391
|
-
style: `font-size: ${attributes.fontSize}`
|
|
6392
|
-
};
|
|
6393
|
-
}
|
|
6394
|
-
}
|
|
6317
|
+
return [{
|
|
6318
|
+
types: this.options.types,
|
|
6319
|
+
attributes: { fontSize: {
|
|
6320
|
+
default: null,
|
|
6321
|
+
parseHTML: (element) => {
|
|
6322
|
+
var _getStyleProperty;
|
|
6323
|
+
return (_getStyleProperty = (0, import_core11.getStyleProperty)(element, "font-size")) !== null && _getStyleProperty !== void 0 ? _getStyleProperty : element.style.fontSize;
|
|
6324
|
+
},
|
|
6325
|
+
renderHTML: (attributes) => {
|
|
6326
|
+
if (!attributes.fontSize) return {};
|
|
6327
|
+
return { style: `font-size: ${attributes.fontSize}` };
|
|
6395
6328
|
}
|
|
6396
|
-
}
|
|
6397
|
-
];
|
|
6329
|
+
} }
|
|
6330
|
+
}];
|
|
6398
6331
|
},
|
|
6399
6332
|
addCommands() {
|
|
6400
6333
|
return {
|
|
@@ -6407,39 +6340,26 @@ var FontSize = import_core15.Extension.create({
|
|
|
6407
6340
|
};
|
|
6408
6341
|
}
|
|
6409
6342
|
});
|
|
6410
|
-
var LineHeight =
|
|
6343
|
+
var LineHeight = import_core11.Extension.create({
|
|
6411
6344
|
name: "lineHeight",
|
|
6412
6345
|
addOptions() {
|
|
6413
|
-
return {
|
|
6414
|
-
types: ["textStyle"]
|
|
6415
|
-
};
|
|
6346
|
+
return { types: ["textStyle"] };
|
|
6416
6347
|
},
|
|
6417
6348
|
addGlobalAttributes() {
|
|
6418
|
-
return [
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
return (_a = (0, import_core16.getStyleProperty)(element, "line-height")) != null ? _a : element.style.lineHeight;
|
|
6430
|
-
},
|
|
6431
|
-
renderHTML: (attributes) => {
|
|
6432
|
-
if (!attributes.lineHeight) {
|
|
6433
|
-
return {};
|
|
6434
|
-
}
|
|
6435
|
-
return {
|
|
6436
|
-
style: `line-height: ${attributes.lineHeight}`
|
|
6437
|
-
};
|
|
6438
|
-
}
|
|
6439
|
-
}
|
|
6349
|
+
return [{
|
|
6350
|
+
types: this.options.types,
|
|
6351
|
+
attributes: { lineHeight: {
|
|
6352
|
+
default: null,
|
|
6353
|
+
parseHTML: (element) => {
|
|
6354
|
+
var _getStyleProperty;
|
|
6355
|
+
return (_getStyleProperty = (0, import_core11.getStyleProperty)(element, "line-height")) !== null && _getStyleProperty !== void 0 ? _getStyleProperty : element.style.lineHeight;
|
|
6356
|
+
},
|
|
6357
|
+
renderHTML: (attributes) => {
|
|
6358
|
+
if (!attributes.lineHeight) return {};
|
|
6359
|
+
return { style: `line-height: ${attributes.lineHeight}` };
|
|
6440
6360
|
}
|
|
6441
|
-
}
|
|
6442
|
-
];
|
|
6361
|
+
} }
|
|
6362
|
+
}];
|
|
6443
6363
|
},
|
|
6444
6364
|
addCommands() {
|
|
6445
6365
|
return {
|
|
@@ -6452,28 +6372,16 @@ var LineHeight = import_core16.Extension.create({
|
|
|
6452
6372
|
};
|
|
6453
6373
|
}
|
|
6454
6374
|
});
|
|
6455
|
-
var TextStyleKit =
|
|
6375
|
+
var TextStyleKit = import_core11.Extension.create({
|
|
6456
6376
|
name: "textStyleKit",
|
|
6457
6377
|
addExtensions() {
|
|
6458
6378
|
const extensions = [];
|
|
6459
|
-
if (this.options.backgroundColor !== false)
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
if (this.options.
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
if (this.options.fontFamily !== false) {
|
|
6466
|
-
extensions.push(FontFamily.configure(this.options.fontFamily));
|
|
6467
|
-
}
|
|
6468
|
-
if (this.options.fontSize !== false) {
|
|
6469
|
-
extensions.push(FontSize.configure(this.options.fontSize));
|
|
6470
|
-
}
|
|
6471
|
-
if (this.options.lineHeight !== false) {
|
|
6472
|
-
extensions.push(LineHeight.configure(this.options.lineHeight));
|
|
6473
|
-
}
|
|
6474
|
-
if (this.options.textStyle !== false) {
|
|
6475
|
-
extensions.push(TextStyle.configure(this.options.textStyle));
|
|
6476
|
-
}
|
|
6379
|
+
if (this.options.backgroundColor !== false) extensions.push(BackgroundColor.configure(this.options.backgroundColor));
|
|
6380
|
+
if (this.options.color !== false) extensions.push(Color.configure(this.options.color));
|
|
6381
|
+
if (this.options.fontFamily !== false) extensions.push(FontFamily.configure(this.options.fontFamily));
|
|
6382
|
+
if (this.options.fontSize !== false) extensions.push(FontSize.configure(this.options.fontSize));
|
|
6383
|
+
if (this.options.lineHeight !== false) extensions.push(LineHeight.configure(this.options.lineHeight));
|
|
6384
|
+
if (this.options.textStyle !== false) extensions.push(TextStyle.configure(this.options.textStyle));
|
|
6477
6385
|
return extensions;
|
|
6478
6386
|
}
|
|
6479
6387
|
});
|
|
@@ -6544,7 +6452,7 @@ var LegacyPromptSEContent = BaseLegacyPromptSEContent.extend({
|
|
|
6544
6452
|
|
|
6545
6453
|
// src/extensions/editor/figure.ts
|
|
6546
6454
|
var import_react35 = require("@tiptap/react");
|
|
6547
|
-
var
|
|
6455
|
+
var import_core12 = require("@tiptap/core");
|
|
6548
6456
|
var Figure2 = BaseFigure.extend({
|
|
6549
6457
|
addNodeView() {
|
|
6550
6458
|
const resizeOptions = this.options.resize;
|
|
@@ -6632,7 +6540,7 @@ var Figure2 = BaseFigure.extend({
|
|
|
6632
6540
|
});
|
|
6633
6541
|
imageContainer.appendChild(editButton);
|
|
6634
6542
|
}
|
|
6635
|
-
const resizableView = new
|
|
6543
|
+
const resizableView = new import_core12.ResizableNodeView({
|
|
6636
6544
|
element: imageContainer,
|
|
6637
6545
|
editor,
|
|
6638
6546
|
node,
|
|
@@ -6964,6 +6872,12 @@ function applyUploadResultsToNodes(imagesToNodes, results) {
|
|
|
6964
6872
|
node.attrs.storageKey = result.storageKey;
|
|
6965
6873
|
});
|
|
6966
6874
|
}
|
|
6875
|
+
function shouldHandleInsertedFile(file, event) {
|
|
6876
|
+
if (!file) return false;
|
|
6877
|
+
event.preventDefault();
|
|
6878
|
+
event.stopPropagation();
|
|
6879
|
+
return file.type.startsWith("image/");
|
|
6880
|
+
}
|
|
6967
6881
|
|
|
6968
6882
|
// src/editor/handlers/insertion-handlers.ts
|
|
6969
6883
|
function useInsertionHandlers(imageHandlers) {
|
|
@@ -6975,9 +6889,7 @@ function useInsertionHandlers(imageHandlers) {
|
|
|
6975
6889
|
}
|
|
6976
6890
|
}, [insertedImage, activeDialog]);
|
|
6977
6891
|
function genericInsertionHandler(file, event) {
|
|
6978
|
-
event
|
|
6979
|
-
event.stopPropagation();
|
|
6980
|
-
if (!file || !file.type.startsWith("image/")) return;
|
|
6892
|
+
if (!file || !shouldHandleInsertedFile(file, event)) return;
|
|
6981
6893
|
if (!imageHandlers?.upload) return;
|
|
6982
6894
|
setInsertedImage(file);
|
|
6983
6895
|
openDialogCommand("image");
|
|
@@ -7013,7 +6925,9 @@ function useInsertionHandlers(imageHandlers) {
|
|
|
7013
6925
|
setDisabled(false);
|
|
7014
6926
|
});
|
|
7015
6927
|
} else {
|
|
7016
|
-
view.dispatch(
|
|
6928
|
+
view.dispatch(
|
|
6929
|
+
view.state.tr.replaceSelection(removeImagesFromSlice(slice))
|
|
6930
|
+
);
|
|
7017
6931
|
}
|
|
7018
6932
|
return true;
|
|
7019
6933
|
}
|
|
@@ -7028,7 +6942,7 @@ function useInsertionHandlers(imageHandlers) {
|
|
|
7028
6942
|
|
|
7029
6943
|
// src/editor/commands/suggestion.tsx
|
|
7030
6944
|
var import_dom = require("@floating-ui/dom");
|
|
7031
|
-
var
|
|
6945
|
+
var import_core13 = require("@tiptap/core");
|
|
7032
6946
|
var import_react37 = require("@tiptap/react");
|
|
7033
6947
|
|
|
7034
6948
|
// src/editor/commands/items.ts
|
|
@@ -7372,7 +7286,7 @@ var createSuggestions = (translations2, hasImageHandlers) => ({
|
|
|
7372
7286
|
component.element.style.position = "absolute";
|
|
7373
7287
|
document.body.appendChild(component.element);
|
|
7374
7288
|
const virtualElement = {
|
|
7375
|
-
getBoundingClientRect: () => (0,
|
|
7289
|
+
getBoundingClientRect: () => (0, import_core13.posToDOMRect)(
|
|
7376
7290
|
props.editor.view,
|
|
7377
7291
|
props.editor.state.selection.from,
|
|
7378
7292
|
props.editor.state.selection.to
|
|
@@ -7399,7 +7313,7 @@ var createSuggestions = (translations2, hasImageHandlers) => ({
|
|
|
7399
7313
|
return;
|
|
7400
7314
|
}
|
|
7401
7315
|
const virtualElement = {
|
|
7402
|
-
getBoundingClientRect: () => (0,
|
|
7316
|
+
getBoundingClientRect: () => (0, import_core13.posToDOMRect)(
|
|
7403
7317
|
props.editor.view,
|
|
7404
7318
|
props.editor.state.selection.from,
|
|
7405
7319
|
props.editor.state.selection.to
|
|
@@ -8010,7 +7924,7 @@ var Tiptap = (props) => {
|
|
|
8010
7924
|
};
|
|
8011
7925
|
|
|
8012
7926
|
// src/utils/html-to-tiptap-content.ts
|
|
8013
|
-
var
|
|
7927
|
+
var import_core14 = require("@tiptap/core");
|
|
8014
7928
|
var import_extension_table2 = require("@tiptap/extension-table");
|
|
8015
7929
|
function isJSONContent(value) {
|
|
8016
7930
|
return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
|
|
@@ -8034,7 +7948,7 @@ function htmlToTiptapContent(content, options = {}) {
|
|
|
8034
7948
|
const sharedExtensions = getSharedExtensions(options);
|
|
8035
7949
|
const extensions = [...sharedExtensions, BaseFigure, import_extension_table2.TableKit, BaseCodeBlock];
|
|
8036
7950
|
try {
|
|
8037
|
-
return (0,
|
|
7951
|
+
return (0, import_core14.generateJSON)(content, extensions);
|
|
8038
7952
|
} catch (error) {
|
|
8039
7953
|
console.error("Failed to convert HTML to Tiptap content:", error);
|
|
8040
7954
|
return { type: "doc", content: [{ type: "paragraph" }] };
|