@contentful/field-editor-rich-text 2.0.0-next.20 → 2.0.0-next.21

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.
@@ -1,5 +1,5 @@
1
1
  import React__default, { createContext, useContext, useMemo, createElement, useEffect, useState, memo, Fragment, useCallback } from 'react';
2
- import { useEntities, ScheduledIconWithTooltip, MissingEntityCard, AssetThumbnail, getScheduleTooltipContent, EntityProvider } from '@contentful/field-editor-reference';
2
+ import { useEntities, ScheduledIconWithTooltip, MissingEntityCard, AssetThumbnail, EntityProvider, getScheduleTooltipContent } from '@contentful/field-editor-reference';
3
3
  import { entityHelpers, shortenStorageUnit, isValidImage, ModalDialogLauncher, FieldConnector } from '@contentful/field-editor-shared';
4
4
  import { BLOCKS, INLINES, TABLE_BLOCKS, TEXT_CONTAINERS, HEADINGS, LIST_ITEM_BLOCKS, MARKS, CONTAINERS, TOP_LEVEL_BLOCKS, VOID_BLOCKS, EMPTY_DOCUMENT } from '@contentful/rich-text-types';
5
5
  import { usePlateEditorState, usePlateEditorRef, getNodes, toggleNodeType, getText, getAbove, setNodes, isAncestorEmpty, getParent, getBlockAbove, isSelectionAtBlockStart, isSelectionAtBlockEnd, isFirstChild, insertNodes, moveChildren, isBlockAboveEmpty, mockPlugin, getPluginType, ELEMENT_DEFAULT, findNode, unwrapNodes, deleteFragment, isCollapsed, isRangeAcrossBlocks, wrapNodes, isMarkActive, toggleMark, someHtmlElement, match, KEY_DESERIALIZE_HTML, hasSingleChild, isLastChild, someNode, getChildren as getChildren$1, getLastChildPath, createDeserializeHtmlPlugin, createDeserializeAstPlugin, createPlateEditor, getPlateActions, Plate } from '@udecode/plate-core';
@@ -2270,15 +2270,7 @@ function FetchingWrappedInlineEntryCard(props) {
2270
2270
  return /*#__PURE__*/React__default.createElement(InlineEntryCard, {
2271
2271
  testId: INLINES.EMBEDDED_ENTRY,
2272
2272
  isSelected: props.isSelected,
2273
- title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", null, contentTypeName, " ", title), /*#__PURE__*/React__default.createElement(ScheduledIconWithTooltip, {
2274
- getEntityScheduledActions: loadEntityScheduledActions,
2275
- entityType: "Entry",
2276
- entityId: entry.sys.id
2277
- }, /*#__PURE__*/React__default.createElement(ClockIcon, {
2278
- className: styles$5.scheduledIcon,
2279
- variant: "muted",
2280
- testId: "scheduled-icon"
2281
- }))),
2273
+ title: contentTypeName + ": " + title,
2282
2274
  status: status,
2283
2275
  actions: [/*#__PURE__*/React__default.createElement(MenuItem, {
2284
2276
  key: "edit",
@@ -2290,7 +2282,15 @@ function FetchingWrappedInlineEntryCard(props) {
2290
2282
  disabled: props.isDisabled,
2291
2283
  testId: "card-action-remove"
2292
2284
  }, "Remove")]
2293
- });
2285
+ }, /*#__PURE__*/React__default.createElement(ScheduledIconWithTooltip, {
2286
+ getEntityScheduledActions: loadEntityScheduledActions,
2287
+ entityType: "Entry",
2288
+ entityId: entry.sys.id
2289
+ }, /*#__PURE__*/React__default.createElement(ClockIcon, {
2290
+ className: styles$5.scheduledIcon,
2291
+ variant: "muted",
2292
+ testId: "scheduled-icon"
2293
+ })), /*#__PURE__*/React__default.createElement(Text$1, null, title));
2294
2294
  }
2295
2295
 
2296
2296
  function createInlineEntryNode(id) {
@@ -2972,159 +2972,6 @@ var createHrPlugin = function createHrPlugin() {
2972
2972
  };
2973
2973
  };
2974
2974
 
2975
- function truncate(str, length) {
2976
- if (typeof str === 'string' && str.length > length) {
2977
- return str && str.substr(0, length + 1) // +1 to look ahead and be replaced below.
2978
- // Get rid of orphan letters but not one letter words (I, a, 2).
2979
- // Try to not have “.” as last character to avoid awkward “....”.
2980
- .replace(/(\s+\S(?=\S)|\s*)\.?.$/, '…');
2981
- }
2982
-
2983
- return str;
2984
- }
2985
-
2986
- function getEntityInfo(_ref) {
2987
- var entityTitle = _ref.entityTitle,
2988
- entityStatus = _ref.entityStatus,
2989
- contentTypeName = _ref.contentTypeName;
2990
- var title = truncate(entityTitle, 60) || 'Untitled';
2991
- return (contentTypeName || 'Asset') + " \"" + title + "\", " + entityStatus;
2992
- }
2993
-
2994
- function EntryAssetTooltip(_ref2) {
2995
- var id = _ref2.id,
2996
- type = _ref2.type,
2997
- sdk = _ref2.sdk;
2998
-
2999
- var _React$useState = useState(''),
3000
- entityTitle = _React$useState[0],
3001
- setEntityTitle = _React$useState[1];
3002
-
3003
- var _React$useState2 = useState(''),
3004
- entityStatus = _React$useState2[0],
3005
- setEntityStatus = _React$useState2[1];
3006
-
3007
- var _React$useState3 = useState([]),
3008
- jobs = _React$useState3[0],
3009
- setJobs = _React$useState3[1];
3010
-
3011
- var _React$useState4 = useState(true),
3012
- isLoading = _React$useState4[0],
3013
- setIsLoading = _React$useState4[1];
3014
-
3015
- var _React$useState5 = useState(false),
3016
- hasError = _React$useState5[0],
3017
- setHasError = _React$useState5[1];
3018
-
3019
- useEffect(function () {
3020
- function loadContent() {
3021
- return _loadContent.apply(this, arguments);
3022
- }
3023
-
3024
- function _loadContent() {
3025
- _loadContent = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
3026
- var actions, contentType, entity, contentTypeId, contentTypes, _entityTitle, _jobs, _entityStatus;
3027
-
3028
- return runtime_1.wrap(function _callee$(_context) {
3029
- while (1) {
3030
- switch (_context.prev = _context.next) {
3031
- case 0:
3032
- _context.prev = 0;
3033
- setIsLoading(true);
3034
- setHasError(false);
3035
- actions = {
3036
- Asset: {
3037
- getEntity: sdk.space.getAsset,
3038
- getEntityTitle: function getEntityTitle(args) {
3039
- return entityHelpers.getAssetTitle(_extends({}, args, {
3040
- asset: args.entity
3041
- }));
3042
- }
3043
- },
3044
- Entry: {
3045
- getEntity: sdk.space.getEntry,
3046
- getEntityTitle: function getEntityTitle(args) {
3047
- return entityHelpers.getEntryTitle(_extends({}, args, {
3048
- entry: args.entity
3049
- }));
3050
- }
3051
- }
3052
- };
3053
- _context.next = 6;
3054
- return actions[type].getEntity(id);
3055
-
3056
- case 6:
3057
- entity = _context.sent;
3058
-
3059
- if (entity.sys.contentType) {
3060
- contentTypeId = entity.sys.contentType.sys.id;
3061
- contentTypes = sdk.space.getCachedContentTypes();
3062
- contentType = contentTypes.find(function (ct) {
3063
- return ct.sys.id === contentTypeId;
3064
- });
3065
- }
3066
-
3067
- _entityTitle = actions[type].getEntityTitle({
3068
- entity: entity,
3069
- contentType: contentType,
3070
- localeCode: sdk.field.locale,
3071
- defaultLocaleCode: sdk.locales["default"],
3072
- entityType: type
3073
- });
3074
- _context.next = 11;
3075
- return sdk.space.getEntityScheduledActions(type, id);
3076
-
3077
- case 11:
3078
- _jobs = _context.sent;
3079
- _entityStatus = entityHelpers.getEntryStatus(entity.sys);
3080
- setEntityTitle(_entityTitle);
3081
- setEntityStatus(_entityStatus);
3082
- setJobs(_jobs);
3083
- _context.next = 22;
3084
- break;
3085
-
3086
- case 18:
3087
- _context.prev = 18;
3088
- _context.t0 = _context["catch"](0);
3089
- console.log(_context.t0);
3090
- setHasError(true);
3091
-
3092
- case 22:
3093
- _context.prev = 22;
3094
- setIsLoading(false);
3095
- return _context.finish(22);
3096
-
3097
- case 25:
3098
- case "end":
3099
- return _context.stop();
3100
- }
3101
- }
3102
- }, _callee, null, [[0, 18, 22, 25]]);
3103
- }));
3104
- return _loadContent.apply(this, arguments);
3105
- }
3106
-
3107
- loadContent();
3108
- }, [id, type, sdk]);
3109
-
3110
- if (isLoading) {
3111
- return /*#__PURE__*/createElement(Fragment, null, "Loading " + type.toLowerCase() + "...");
3112
- }
3113
-
3114
- if (hasError) {
3115
- return /*#__PURE__*/createElement(Fragment, null, type + " missing or inaccessible");
3116
- }
3117
-
3118
- return /*#__PURE__*/createElement(Fragment, null, getEntityInfo({
3119
- entityTitle: entityTitle,
3120
- contentTypeName: type,
3121
- entityStatus: entityStatus
3122
- }), ' ', jobs.length > 0 ? getScheduleTooltipContent({
3123
- job: jobs[0],
3124
- jobsCount: jobs.length
3125
- }) : '');
3126
- }
3127
-
3128
2975
  var _templateObject$3, _SYS_LINK_TYPES, _LINK_TYPE_SELECTION_;
3129
2976
  var styles$b = {
3130
2977
  removeSelectionLabel: /*#__PURE__*/css(_templateObject$3 || (_templateObject$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-left: ", ";\n "])), tokens.spacingS)
@@ -3436,11 +3283,213 @@ function _addOrEditLink() {
3436
3283
  return _addOrEditLink.apply(this, arguments);
3437
3284
  }
3438
3285
 
3286
+ function ToolbarHyperlinkButton(props) {
3287
+ var editor = useContentfulEditor();
3288
+ var isActive = !!(editor && isLinkActive(editor));
3289
+ var sdk = useSdkContext();
3290
+
3291
+ function handleClick() {
3292
+ return _handleClick.apply(this, arguments);
3293
+ }
3294
+
3295
+ function _handleClick() {
3296
+ _handleClick = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
3297
+ return runtime_1.wrap(function _callee$(_context) {
3298
+ while (1) {
3299
+ switch (_context.prev = _context.next) {
3300
+ case 0:
3301
+ if (editor) {
3302
+ _context.next = 2;
3303
+ break;
3304
+ }
3305
+
3306
+ return _context.abrupt("return");
3307
+
3308
+ case 2:
3309
+ if (isActive) {
3310
+ unwrapLink(editor);
3311
+ editor.tracking.onToolbarAction('unlinkHyperlinks');
3312
+ } else {
3313
+ addOrEditLink(editor, sdk, editor.tracking.onToolbarAction);
3314
+ }
3315
+
3316
+ case 3:
3317
+ case "end":
3318
+ return _context.stop();
3319
+ }
3320
+ }
3321
+ }, _callee);
3322
+ }));
3323
+ return _handleClick.apply(this, arguments);
3324
+ }
3325
+
3326
+ if (!editor) return null;
3327
+ return /*#__PURE__*/createElement(ToolbarButton, {
3328
+ title: "Hyperlink",
3329
+ testId: "hyperlink-toolbar-button",
3330
+ onClick: handleClick,
3331
+ isActive: isActive,
3332
+ isDisabled: props.isDisabled
3333
+ }, /*#__PURE__*/createElement(LinkIcon, null));
3334
+ }
3335
+
3439
3336
  var hasText = function hasText(editor, entry) {
3440
3337
  var node = entry[0];
3441
3338
  return !isAncestorEmpty(editor, node) && Node.string(node).trim() !== '';
3442
3339
  };
3443
3340
 
3341
+ function truncate(str, length) {
3342
+ if (typeof str === 'string' && str.length > length) {
3343
+ return str && str.substr(0, length + 1) // +1 to look ahead and be replaced below.
3344
+ // Get rid of orphan letters but not one letter words (I, a, 2).
3345
+ // Try to not have “.” as last character to avoid awkward “....”.
3346
+ .replace(/(\s+\S(?=\S)|\s*)\.?.$/, '…');
3347
+ }
3348
+
3349
+ return str;
3350
+ }
3351
+
3352
+ function getEntityInfo(data) {
3353
+ if (!data) {
3354
+ return '';
3355
+ }
3356
+
3357
+ var entityTitle = data.entityTitle,
3358
+ contentTypeName = data.contentTypeName,
3359
+ entityStatus = data.entityStatus,
3360
+ jobs = data.jobs;
3361
+ var title = truncate(entityTitle, 60) || 'Untitled';
3362
+ var scheduledActions = jobs.length > 0 ? getScheduleTooltipContent({
3363
+ job: jobs[0],
3364
+ jobsCount: jobs.length
3365
+ }) : '';
3366
+ return (contentTypeName || 'Asset') + " \"" + title + "\", " + entityStatus + " " + scheduledActions;
3367
+ }
3368
+
3369
+ function fetchAllData(_x) {
3370
+ return _fetchAllData.apply(this, arguments);
3371
+ }
3372
+
3373
+ function _fetchAllData() {
3374
+ _fetchAllData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref) {
3375
+ var sdk, entityId, entityType, localeCode, defaultLocaleCode, contentType, getEntity, entity, contentTypeId, entityTitle, entityDescription, jobs, entityStatus;
3376
+ return runtime_1.wrap(function _callee$(_context) {
3377
+ while (1) {
3378
+ switch (_context.prev = _context.next) {
3379
+ case 0:
3380
+ sdk = _ref.sdk, entityId = _ref.entityId, entityType = _ref.entityType, localeCode = _ref.localeCode, defaultLocaleCode = _ref.defaultLocaleCode;
3381
+ getEntity = entityType === 'Entry' ? sdk.space.getEntry : sdk.space.getAsset;
3382
+ _context.next = 4;
3383
+ return getEntity(entityId);
3384
+
3385
+ case 4:
3386
+ entity = _context.sent;
3387
+
3388
+ if (entity.sys.contentType) {
3389
+ contentTypeId = entity.sys.contentType.sys.id;
3390
+ contentType = sdk.space.getCachedContentTypes().find(function (ct) {
3391
+ return ct.sys.id === contentTypeId;
3392
+ });
3393
+ }
3394
+
3395
+ entityTitle = entityType === 'Entry' ? entityHelpers.getEntryTitle({
3396
+ entry: entity,
3397
+ contentType: contentType,
3398
+ localeCode: localeCode,
3399
+ defaultLocaleCode: defaultLocaleCode,
3400
+ defaultTitle: 'Untitled'
3401
+ }) : entityHelpers.getAssetTitle({
3402
+ asset: entity,
3403
+ localeCode: localeCode,
3404
+ defaultLocaleCode: defaultLocaleCode,
3405
+ defaultTitle: 'Untitled'
3406
+ });
3407
+ entityDescription = entityHelpers.getEntityDescription({
3408
+ entity: entity,
3409
+ contentType: contentType,
3410
+ localeCode: localeCode,
3411
+ defaultLocaleCode: defaultLocaleCode
3412
+ });
3413
+ _context.next = 10;
3414
+ return sdk.space.getEntityScheduledActions(entityType, entityId);
3415
+
3416
+ case 10:
3417
+ jobs = _context.sent;
3418
+ entityStatus = entityHelpers.getEntryStatus(entity.sys);
3419
+ return _context.abrupt("return", {
3420
+ jobs: jobs,
3421
+ entity: entity,
3422
+ entityTitle: entityTitle,
3423
+ entityDescription: entityDescription,
3424
+ entityStatus: entityStatus,
3425
+ contentTypeName: contentType ? contentType.name : ''
3426
+ });
3427
+
3428
+ case 13:
3429
+ case "end":
3430
+ return _context.stop();
3431
+ }
3432
+ }
3433
+ }, _callee);
3434
+ }));
3435
+ return _fetchAllData.apply(this, arguments);
3436
+ }
3437
+
3438
+ function useRequestStatus(_ref2) {
3439
+ var sdk = _ref2.sdk,
3440
+ target = _ref2.target,
3441
+ onEntityFetchComplete = _ref2.onEntityFetchComplete;
3442
+
3443
+ var _useState = useState({
3444
+ type: 'loading'
3445
+ }),
3446
+ requestStatus = _useState[0],
3447
+ setRequestStatus = _useState[1];
3448
+
3449
+ useEffect(function () {
3450
+ if (target) {
3451
+ var _target$sys, _target$sys2;
3452
+
3453
+ fetchAllData({
3454
+ sdk: sdk,
3455
+ entityId: target == null ? void 0 : (_target$sys = target.sys) == null ? void 0 : _target$sys.id,
3456
+ entityType: target == null ? void 0 : (_target$sys2 = target.sys) == null ? void 0 : _target$sys2.linkType,
3457
+ localeCode: sdk.field.locale,
3458
+ defaultLocaleCode: sdk.locales["default"]
3459
+ }).then(function (entityInfo) {
3460
+ setRequestStatus({
3461
+ type: 'success',
3462
+ data: entityInfo
3463
+ });
3464
+ })["catch"](function (e) {
3465
+ console.log(e);
3466
+ setRequestStatus({
3467
+ type: 'error',
3468
+ error: e
3469
+ });
3470
+ })["finally"](function () {
3471
+ onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();
3472
+ });
3473
+ }
3474
+ }, [sdk, target, onEntityFetchComplete]);
3475
+ return requestStatus;
3476
+ }
3477
+
3478
+ function useEntityInfo(props) {
3479
+ var status = useRequestStatus(props);
3480
+ var linkType = props.target.sys.linkType;
3481
+
3482
+ if (status.type === 'loading') {
3483
+ return "Loading " + linkType.toLowerCase() + "...";
3484
+ }
3485
+
3486
+ if (status.type === 'error') {
3487
+ return linkType + " missing or inaccessible";
3488
+ }
3489
+
3490
+ return getEntityInfo(status.data);
3491
+ }
3492
+
3444
3493
  var styles$c = {
3445
3494
  hyperlinkWrapper: /*#__PURE__*/css({
3446
3495
  display: 'inline',
@@ -3458,33 +3507,21 @@ var styles$c = {
3458
3507
  '&:focus': {
3459
3508
  fill: tokens.gray900
3460
3509
  }
3461
- }),
3462
- hyperlinkIEFallback: /*#__PURE__*/css({
3463
- color: '#1683d0',
3464
- textDecoration: 'underline'
3465
- }),
3466
- // TODO: use these styles once we can use the icon
3467
- hyperlinkIcon: /*#__PURE__*/css({
3468
- position: 'relative',
3469
- top: '4px',
3470
- height: '14px',
3471
- margin: '0 -2px 0 -1px',
3472
- webkitTransition: 'fill 100ms ease-in-out',
3473
- transition: 'fill 100ms ease-in-out',
3474
- '&:hover': {
3475
- fill: tokens.gray900
3476
- },
3477
- '&:focus': {
3478
- fill: tokens.gray900
3479
- }
3480
3510
  })
3481
3511
  };
3482
3512
 
3483
- function UrlHyperlink(props) {
3513
+ function EntityHyperlink(props) {
3484
3514
  var editor = useContentfulEditor();
3485
3515
  var isReadOnly = useReadOnly();
3486
3516
  var sdk = useSdkContext();
3487
- var uri = props.element.data.uri;
3517
+ var target = props.element.data.target;
3518
+ var onEntityFetchComplete = props.onEntityFetchComplete;
3519
+ var tooltipContent = useEntityInfo({
3520
+ target: target,
3521
+ sdk: sdk,
3522
+ onEntityFetchComplete: onEntityFetchComplete
3523
+ });
3524
+ if (!target) return null;
3488
3525
 
3489
3526
  function handleClick(event) {
3490
3527
  event.preventDefault();
@@ -3494,33 +3531,25 @@ function UrlHyperlink(props) {
3494
3531
  }
3495
3532
 
3496
3533
  return /*#__PURE__*/createElement(Tooltip, {
3497
- content: uri,
3534
+ content: tooltipContent,
3498
3535
  targetWrapperClassName: styles$c.hyperlinkWrapper,
3499
3536
  placement: "bottom",
3500
3537
  maxWidth: "auto"
3501
3538
  }, /*#__PURE__*/createElement(TextLink, {
3502
3539
  as: "a",
3503
- href: uri,
3504
- rel: "noopener noreferrer",
3505
3540
  onClick: handleClick,
3506
3541
  isDisabled: isReadOnly,
3507
- className: styles$c.hyperlink
3542
+ className: styles$c.hyperlink,
3543
+ "data-link-type": target.sys.linkType,
3544
+ "data-link-id": target.sys.id
3508
3545
  }, props.children));
3509
3546
  }
3510
3547
 
3511
- function EntityHyperlink(props) {
3548
+ function UrlHyperlink(props) {
3512
3549
  var editor = useContentfulEditor();
3513
3550
  var isReadOnly = useReadOnly();
3514
3551
  var sdk = useSdkContext();
3515
- var target = props.element.data.target;
3516
- var onEntityFetchComplete = props.onEntityFetchComplete;
3517
- useEffect(function () {
3518
- // The real entity loading happens in the tooltip
3519
- // Since that is deferred the link is considered rendered as soon
3520
- // the component mounts (link text displayed)
3521
- onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();
3522
- }, [onEntityFetchComplete]);
3523
- if (!target) return null;
3552
+ var uri = props.element.data.uri;
3524
3553
 
3525
3554
  function handleClick(event) {
3526
3555
  event.preventDefault();
@@ -3530,74 +3559,20 @@ function EntityHyperlink(props) {
3530
3559
  }
3531
3560
 
3532
3561
  return /*#__PURE__*/createElement(Tooltip, {
3533
- content: /*#__PURE__*/createElement(EntryAssetTooltip, {
3534
- id: target.sys.id,
3535
- type: target.sys.linkType,
3536
- sdk: sdk
3537
- }),
3562
+ content: uri,
3538
3563
  targetWrapperClassName: styles$c.hyperlinkWrapper,
3539
3564
  placement: "bottom",
3540
3565
  maxWidth: "auto"
3541
3566
  }, /*#__PURE__*/createElement(TextLink, {
3542
3567
  as: "a",
3568
+ href: uri,
3569
+ rel: "noopener noreferrer",
3543
3570
  onClick: handleClick,
3544
3571
  isDisabled: isReadOnly,
3545
- className: styles$c.hyperlink,
3546
- "data-link-type": target.sys.linkType,
3547
- "data-link-id": target.sys.id
3572
+ className: styles$c.hyperlink
3548
3573
  }, props.children));
3549
3574
  }
3550
3575
 
3551
- function ToolbarHyperlinkButton(props) {
3552
- var editor = useContentfulEditor();
3553
- var isActive = !!(editor && isLinkActive(editor));
3554
- var sdk = useSdkContext();
3555
-
3556
- function handleClick() {
3557
- return _handleClick.apply(this, arguments);
3558
- }
3559
-
3560
- function _handleClick() {
3561
- _handleClick = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
3562
- return runtime_1.wrap(function _callee$(_context) {
3563
- while (1) {
3564
- switch (_context.prev = _context.next) {
3565
- case 0:
3566
- if (editor) {
3567
- _context.next = 2;
3568
- break;
3569
- }
3570
-
3571
- return _context.abrupt("return");
3572
-
3573
- case 2:
3574
- if (isActive) {
3575
- unwrapLink(editor);
3576
- editor.tracking.onToolbarAction('unlinkHyperlinks');
3577
- } else {
3578
- addOrEditLink(editor, sdk, editor.tracking.onToolbarAction);
3579
- }
3580
-
3581
- case 3:
3582
- case "end":
3583
- return _context.stop();
3584
- }
3585
- }
3586
- }, _callee);
3587
- }));
3588
- return _handleClick.apply(this, arguments);
3589
- }
3590
-
3591
- if (!editor) return null;
3592
- return /*#__PURE__*/createElement(ToolbarButton, {
3593
- title: "Hyperlink",
3594
- testId: "hyperlink-toolbar-button",
3595
- onClick: handleClick,
3596
- isActive: isActive,
3597
- isDisabled: props.isDisabled
3598
- }, /*#__PURE__*/createElement(LinkIcon, null));
3599
- }
3600
-
3601
3576
  var isAnchor = function isAnchor(element) {
3602
3577
  return element.nodeName === 'A' && !!element.getAttribute('href') && element.getAttribute('href') !== '#';
3603
3578
  };