pageflow 15.7.1 → 16.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -243
- data/README.md +1 -9
- data/Rakefile +4 -1
- data/admins/pageflow/accounts.rb +12 -16
- data/admins/pageflow/entry.rb +57 -28
- data/admins/pageflow/entry_templates.rb +5 -7
- data/admins/pageflow/sites.rb +50 -0
- data/admins/pageflow/user.rb +7 -0
- data/app/assets/javascripts/pageflow/admin/entries.js +53 -4
- data/app/assets/stylesheets/pageflow/admin/permalink_input.scss +65 -0
- data/app/assets/stylesheets/pageflow/admin.scss +1 -0
- data/app/assets/stylesheets/pageflow/editor/base.scss +2 -6
- data/app/assets/stylesheets/pageflow/editor/dialogs.scss +2 -0
- data/app/assets/stylesheets/pageflow/editor/drop_down_button.scss +9 -0
- data/app/assets/stylesheets/pageflow/editor/info_box.scss +13 -3
- data/app/assets/stylesheets/pageflow/mixins/buttons.scss +1 -0
- data/app/assets/stylesheets/pageflow/page.scss +0 -2
- data/app/assets/stylesheets/pageflow/themes/default/page.scss +1 -1
- data/app/assets/stylesheets/pageflow/ui/forms.scss +4 -1
- data/app/controllers/pageflow/editor/file_import_controller.rb +32 -42
- data/app/controllers/pageflow/entries_controller.rb +27 -3
- data/app/helpers/pageflow/admin/permalinks_helper.rb +15 -0
- data/app/helpers/pageflow/common_entry_seed_helper.rb +1 -1
- data/app/helpers/pageflow/embed_code_helper.rb +1 -1
- data/app/helpers/pageflow/entries_helper.rb +25 -17
- data/app/helpers/pageflow/sites_helper.rb +11 -0
- data/app/helpers/pageflow/social_share_helper.rb +2 -2
- data/app/inputs/pageflow_permalink_input.rb +47 -0
- data/app/models/concerns/pageflow/permalinkable.rb +12 -0
- data/app/models/concerns/pageflow/reusable_file.rb +5 -0
- data/app/models/concerns/pageflow/uploadable_file.rb +4 -0
- data/app/models/pageflow/account.rb +7 -33
- data/app/models/pageflow/{cname_theming_request_scope.rb → cname_site_request_scope.rb} +3 -3
- data/app/models/pageflow/customized_theme.rb +5 -3
- data/app/models/pageflow/entry.rb +8 -4
- data/app/models/pageflow/entry_at_revision.rb +4 -3
- data/app/models/pageflow/entry_duplicate.rb +8 -1
- data/app/models/pageflow/entry_template.rb +4 -4
- data/app/models/pageflow/home_button.rb +7 -7
- data/app/models/pageflow/image_file_url_templates.rb +2 -2
- data/app/models/pageflow/permalink.rb +39 -0
- data/app/models/pageflow/permalink_directory.rb +10 -0
- data/app/models/pageflow/published_entry.rb +19 -2
- data/app/models/pageflow/revision.rb +1 -1
- data/app/models/pageflow/site.rb +59 -0
- data/app/models/pageflow/theme_customization.rb +1 -1
- data/app/models/pageflow/theme_customization_file.rb +6 -1
- data/app/policies/pageflow/account_policy.rb +2 -2
- data/app/policies/pageflow/entry_policy.rb +2 -2
- data/app/policies/pageflow/entry_template_policy.rb +1 -1
- data/app/policies/pageflow/{theming_policy.rb → site_policy.rb} +13 -11
- data/app/views/admin/accounts/_entry_template_details.html.arb +1 -1
- data/app/views/admin/accounts/_form.html.erb +4 -22
- data/app/views/admin/accounts/_site_defaults_inline_help.html.erb +5 -0
- data/app/views/admin/entries/_form.html.erb +11 -12
- data/app/views/admin/entries/_permalink_inputs.html.erb +6 -0
- data/app/views/admin/entries/_site_input.html.erb +15 -0
- data/app/views/admin/entries/{entry_type_name_input.html.erb → entry_site_and_type_name_input.html.erb} +3 -0
- data/app/views/admin/entries/permalink_inputs.html.erb +7 -0
- data/app/views/admin/entry_templates/_form.html.erb +5 -5
- data/app/views/admin/sites/_attributes_table.html.arb +9 -0
- data/app/views/admin/sites/_fields.html.erb +17 -0
- data/app/views/admin/sites/_form.html.erb +5 -0
- data/app/views/components/pageflow/admin/entries_tab.rb +1 -2
- data/app/views/components/pageflow/admin/entry_templates_tab.rb +10 -11
- data/app/views/components/pageflow/admin/features_tab.rb +1 -1
- data/app/views/components/pageflow/admin/sites_tab.rb +32 -0
- data/app/views/components/pageflow/admin/users_tab.rb +1 -2
- data/app/views/pageflow/editor/entries/seed.json.erb +1 -1
- data/app/views/pageflow/editor/file_import/start_import_job.json.jbuilder +10 -0
- data/app/views/pageflow/editor/sites/_site.json.jbuilder +1 -0
- data/app/views/pageflow/entries/{_theming.css.erb → _site.css.erb} +0 -0
- data/app/views/pageflow/entries/stylesheet.css.erb +1 -1
- data/app/views/pageflow/files/_file.json.jbuilder +1 -0
- data/app/views/pageflow/social_share/_entry_meta_tags.html.erb +1 -1
- data/app/views/pageflow/social_share/_page_meta_tags.html.erb +1 -1
- data/config/initializers/admin_resource_tabs.rb +29 -12
- data/config/initializers/mime_types.rb +1 -0
- data/config/locales/de.yml +19 -17
- data/config/locales/en.yml +19 -17
- data/config/routes.rb +8 -5
- data/db/migrate/20221024100724_create_pageflow_permalink_directories.rb +10 -0
- data/db/migrate/20221025074049_add_permalink_attributes_to_entries.rb +5 -0
- data/db/migrate/20221027065022_create_pageflow_permalinks.rb +12 -0
- data/db/migrate/20221215101134_rename_theming_to_site.rb +9 -0
- data/db/migrate/20221215120856_associate_entry_templates_with_sites.rb +34 -0
- data/db/migrate/20221219203023_add_name_to_sites.rb +5 -0
- data/db/migrate/20230103155934_associate_theme_customizations_with_sites.rb +27 -0
- data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/editor.js +176 -179
- data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/frontend.js +49 -7
- data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/react-client.js +5 -5
- data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/react-server.js +1 -1
- data/entry_types/paged/config/initializers/features.rb +2 -0
- data/entry_types/paged/config/locales/{new/help.de.yml → de.yml} +74 -65
- data/entry_types/paged/config/locales/{new/help.en.yml → en.yml} +66 -56
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/favicon_helper.rb +39 -13
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/generated_media_queries_helper.rb +55 -0
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/themes_helper.rb +6 -2
- data/entry_types/scrolled/app/views/pageflow_scrolled/editor/entries/_head.html.erb +2 -0
- data/entry_types/scrolled/app/views/pageflow_scrolled/entries/_manifest.json.jbuilder +16 -0
- data/entry_types/scrolled/app/views/pageflow_scrolled/entries/show.html.erb +9 -3
- data/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_entry.json.jbuilder +5 -5
- data/entry_types/scrolled/app/views/pageflow_scrolled/favicons/_entry.html.erb +16 -10
- data/entry_types/scrolled/config/locales/de.yml +265 -76
- data/entry_types/scrolled/config/locales/en.yml +266 -77
- data/entry_types/scrolled/lib/pageflow_scrolled/configuration.rb +3 -3
- data/entry_types/scrolled/lib/pageflow_scrolled/plugin.rb +14 -0
- data/entry_types/scrolled/lib/pageflow_scrolled/react_widget_type.rb +1 -1
- data/entry_types/scrolled/lib/pageflow_scrolled/seeds.rb +1 -1
- data/entry_types/scrolled/lib/pageflow_scrolled/web_app_manifest.rb +11 -0
- data/entry_types/scrolled/lib/pageflow_scrolled.rb +39 -1
- data/entry_types/scrolled/lib/tasks/pageflow_scrolled/storybook.rake +3 -2
- data/entry_types/scrolled/package/contentElements-editor.js +124 -38
- data/entry_types/scrolled/package/contentElements-frontend.css +1 -1
- data/entry_types/scrolled/package/contentElements-frontend.js +321 -27
- data/entry_types/scrolled/package/editor.js +1345 -739
- data/entry_types/scrolled/package/frontend/EditableInlineText.module-14c7b097.js +5314 -0
- data/entry_types/scrolled/package/frontend/{PhonePlatformContext-9fb97827.js → PhonePlatformContext-f6093cc6.js} +87 -223
- data/entry_types/scrolled/package/frontend/{Viewer-e2290ea0.js → Viewer-b6becc57.js} +6 -40
- data/entry_types/scrolled/package/frontend/arrowRight-78a7cee4.js +42 -0
- data/entry_types/scrolled/package/frontend/{components-6ab26015.js → components-b3160dd7.js} +546 -361
- data/entry_types/scrolled/package/frontend/index.css +1 -1
- data/entry_types/scrolled/package/frontend/index.js +398 -3692
- data/entry_types/scrolled/package/package.json +3 -2
- data/entry_types/scrolled/package/testHelpers.js +12 -2
- data/entry_types/scrolled/package/widgets/defaultNavigation.css +2 -2
- data/entry_types/scrolled/package/widgets/defaultNavigation.js +50 -40
- data/entry_types/scrolled/spec/fixtures/image.ico +0 -0
- data/lib/pageflow/ability_mixin.rb +16 -8
- data/lib/pageflow/admin/attributes_table_rows.rb +1 -1
- data/lib/pageflow/admin/form_inputs.rb +1 -1
- data/lib/pageflow/admin/tabs.rb +1 -1
- data/lib/pageflow/configuration/permissions.rb +3 -3
- data/lib/pageflow/configuration.rb +17 -17
- data/lib/pageflow/entry_export_import/entry_serialization.rb +1 -1
- data/lib/pageflow/entry_type.rb +6 -2
- data/lib/pageflow/primary_domain_entry_redirect.rb +7 -7
- data/lib/pageflow/seeds.rb +10 -10
- data/lib/pageflow/theme_customizations.rb +10 -10
- data/lib/pageflow/version.rb +1 -1
- data/package/editor.js +129 -156
- data/package/frontend.js +19 -2
- data/package/testHelpers.js +39 -6
- data/spec/factories/accounts.rb +5 -2
- data/spec/factories/draft_entries.rb +2 -2
- data/spec/factories/entries.rb +18 -1
- data/spec/factories/entry_templates.rb +1 -1
- data/spec/factories/permalink_directory.rb +6 -0
- data/spec/factories/permalinks.rb +4 -0
- data/spec/factories/published_entries.rb +4 -2
- data/spec/factories/sites.rb +9 -0
- metadata +50 -62
- data/app/assets/javascripts/pageflow/dist/editor.js +0 -11890
- data/app/assets/javascripts/pageflow/dist/frontend.js +0 -5800
- data/app/assets/javascripts/pageflow/dist/react-client.js +0 -22
- data/app/assets/javascripts/pageflow/dist/react-server.js +0 -19
- data/app/helpers/pageflow/themings_helper.rb +0 -11
- data/app/models/pageflow/theming.rb +0 -29
- data/app/views/admin/accounts/_theming_defaults_inline_help.html.erb +0 -5
- data/app/views/admin/accounts/_theming_details.html.arb +0 -5
- data/app/views/pageflow/editor/themings/_theming.json.jbuilder +0 -1
- data/entry_types/paged/config/locales/new/video_contain.de.yml +0 -7
- data/entry_types/paged/config/locales/new/video_contain.en.yml +0 -7
- data/entry_types/scrolled/config/locales/new/before_after_slider.de.yml +0 -8
- data/entry_types/scrolled/config/locales/new/before_after_slider.en.yml +0 -8
- data/entry_types/scrolled/config/locales/new/center_ragged.de.yml +0 -8
- data/entry_types/scrolled/config/locales/new/center_ragged.en.yml +0 -9
- data/entry_types/scrolled/config/locales/new/consent.de.yml +0 -25
- data/entry_types/scrolled/config/locales/new/consent.en.yml +0 -24
- data/entry_types/scrolled/config/locales/new/content_element_categories.de.yml +0 -39
- data/entry_types/scrolled/config/locales/new/content_element_categories.en.yml +0 -39
- data/entry_types/scrolled/config/locales/new/default_transition.de.yml +0 -14
- data/entry_types/scrolled/config/locales/new/default_transition.en.yml +0 -14
- data/entry_types/scrolled/config/locales/new/header_line_breaks.de.yml +0 -28
- data/entry_types/scrolled/config/locales/new/header_line_breaks.en.yml +0 -27
- data/entry_types/scrolled/config/locales/new/header_size.de.yml +0 -17
- data/entry_types/scrolled/config/locales/new/header_size.en.yml +0 -17
- data/entry_types/scrolled/config/locales/new/iframe_embed.de.yml +0 -39
- data/entry_types/scrolled/config/locales/new/iframe_embed.en.yml +0 -39
- data/entry_types/scrolled/config/locales/new/inline_loops.de.yml +0 -26
- data/entry_types/scrolled/config/locales/new/inline_loops.en.yml +0 -26
- data/entry_types/scrolled/config/locales/new/portrait_inline_image.de.yml +0 -9
- data/entry_types/scrolled/config/locales/new/portrait_inline_image.en.yml +0 -9
- data/entry_types/scrolled/config/locales/new/section_width.de.yml +0 -10
- data/entry_types/scrolled/config/locales/new/section_width.en.yml +0 -10
- data/entry_types/scrolled/config/locales/new/typography_variants.de.yml +0 -7
- data/entry_types/scrolled/config/locales/new/typography_variants.en.yml +0 -7
- data/entry_types/scrolled/config/locales/new/video_embed_poster.de.yml +0 -8
- data/entry_types/scrolled/config/locales/new/video_embed_poster.en.yml +0 -8
- data/entry_types/scrolled/config/locales/new/waveform_styles.de.yml +0 -11
- data/entry_types/scrolled/config/locales/new/waveform_styles.en.yml +0 -12
- data/entry_types/scrolled/config/locales/new/widgets.de.yml +0 -6
- data/entry_types/scrolled/config/locales/new/widgets.en.yml +0 -6
- data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/browserconfig.xml +0 -9
- data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/mstile-150x150.png +0 -0
- data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/safari-pinned-tab.svg +0 -46
- data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/site.webmanifest +0 -19
- data/entry_types/scrolled/package/frontend/EditableInlineText.module-b9923660.js +0 -993
- data/entry_types/scrolled/package/frontend/usePhonePlatform-2857c22b.js +0 -34
- data/spec/factories/themings.rb +0 -7
data/entry_types/scrolled/package/frontend/{components-6ab26015.js → components-b3160dd7.js}
RENAMED
@@ -1,16 +1,19 @@
|
|
1
|
-
import
|
2
|
-
import {
|
1
|
+
import 'regenerator-runtime';
|
2
|
+
import { a6 as ContentElementEditorCommandEmitterContext, b as usePostMessageListener, a7 as MotifAreaVisibilityProvider, a8 as ForcePaddingContext, a9 as ContentElementConfigurationUpdateContext, aa as ContentElementEditorStateContext, d as api, z as useContentElementEditorState, ab as LayoutWithoutInlineEditing, a5 as SectionThumbnail, ac as renderElement, ad as renderLeaf$1, y as useContentElementEditorCommandSubscription, T as Text$1, n as frontendStyles } from './EditableInlineText.module-14c7b097.js';
|
3
|
+
import 'pageflow/frontend';
|
4
|
+
import React, { useMemo, useState, useCallback, useContext, useRef, useEffect, createContext, memo } from 'react';
|
5
|
+
import { c as _slicedToArray, o as useEntryStateDispatch, b as _defineProperty, _ as _objectWithoutProperties, u as useI18n, D as updateContentElementConfiguration, q as useChapter, a as _objectSpread2, j as _toConsumableArray, F as _unsupportedIterableToArray, P as PhonePlatformContext } from './PhonePlatformContext-f6093cc6.js';
|
3
6
|
import 'i18n-js';
|
4
7
|
import 'use-context-selector';
|
5
8
|
import 'reselect';
|
6
9
|
import 'slugify';
|
7
10
|
import classNames from 'classnames';
|
8
|
-
import { C as ContentElementEditorCommandEmitterContext, e as usePostMessageListener, n as MotifAreaVisibilityProvider, o as ForcePaddingContext, p as ContentElementConfigurationUpdateContext, q as ContentElementEditorStateContext, f as api, u as useContentElementEditorState, r as LayoutWithoutInlineEditing, s as renderElement, t as renderLeaf$1, j as useContentElementEditorCommandSubscription, T as Text$1, h as frontendStyles } from './EditableInlineText.module-b9923660.js';
|
9
11
|
import './createSuper-d0f30da3.js';
|
10
12
|
import BackboneEvents from 'backbone-events-standalone';
|
13
|
+
import 'react-measure';
|
11
14
|
import { DndProvider, useDrop, useDrag } from 'react-dnd';
|
12
15
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
13
|
-
import { Range, Editor, Transforms,
|
16
|
+
import { Range, Editor, Transforms, Node, Element, Path, Text, createEditor } from 'slate';
|
14
17
|
import { useSlate, ReactEditor, withReact, Slate, Editable } from 'slate-react';
|
15
18
|
import debounce from 'debounce';
|
16
19
|
|
@@ -650,6 +653,11 @@ function postUpdateTransientContentElementStateMessage(_ref4) {
|
|
650
653
|
}
|
651
654
|
}, window.location.origin);
|
652
655
|
}
|
656
|
+
function postSelectLinkDestinationMessage() {
|
657
|
+
window.parent.postMessage({
|
658
|
+
type: 'SELECT_LINK_DESTINATION'
|
659
|
+
}, window.location.origin);
|
660
|
+
}
|
653
661
|
|
654
662
|
function ContentElementConfigurationUpdateProvider(_ref) {
|
655
663
|
var id = _ref.id,
|
@@ -969,7 +977,7 @@ function withCustomInsertBreak(editor) {
|
|
969
977
|
return editor;
|
970
978
|
}
|
971
979
|
|
972
|
-
var styles$7 = {"container":"index-module_container__3dD9z","hoveringToolbar":"index-module_hoveringToolbar__31Xpd","selection":"index-module_selection__3dUiD","linkTooltip":"index-module_linkTooltip__36m1K"};
|
980
|
+
var styles$7 = {"container":"index-module_container__3dD9z","shy":"index-module_shy__KgWjc","selected":"index-module_selected__mE58y","hoveringToolbar":"index-module_hoveringToolbar__31Xpd","selection":"index-module_selection__3dUiD","linkTooltip":"index-module_linkTooltip__36m1K","linkTooltipThumbnail":"index-module_linkTooltipThumbnail__2v-cf","linkTooltipThumbnailClickMask":"index-module_linkTooltipThumbnailClickMask__2Z3ff","linkTooltipNewTab":"index-module_linkTooltipNewTab__4tnLF","linkTooltipChapterNumber":"index-module_linkTooltipChapterNumber__2CsQA"};
|
973
981
|
|
974
982
|
function _extends$3() {
|
975
983
|
_extends$3 = Object.assign || function (target) {
|
@@ -1006,11 +1014,10 @@ var ExternalLinkIcon = (function (_ref) {
|
|
1006
1014
|
}));
|
1007
1015
|
});
|
1008
1016
|
|
1009
|
-
var DisabledContext = createContext();
|
1010
|
-
var StateContext = createContext();
|
1011
1017
|
var UpdateContext = createContext();
|
1012
1018
|
function LinkTooltipProvider(_ref) {
|
1013
|
-
var
|
1019
|
+
var editor = _ref.editor,
|
1020
|
+
disabled = _ref.disabled,
|
1014
1021
|
children = _ref.children;
|
1015
1022
|
|
1016
1023
|
var _useState = useState(),
|
@@ -1022,13 +1029,14 @@ function LinkTooltipProvider(_ref) {
|
|
1022
1029
|
var update = useMemo(function () {
|
1023
1030
|
var timeout;
|
1024
1031
|
return {
|
1025
|
-
activate: function activate(href, linkRef) {
|
1032
|
+
activate: function activate(href, openInNewTab, linkRef) {
|
1026
1033
|
clearTimeout(timeout);
|
1027
1034
|
timeout = null;
|
1028
1035
|
var outerRect = outerRef.current.getBoundingClientRect();
|
1029
1036
|
var linkRect = linkRef.current.getBoundingClientRect();
|
1030
1037
|
setState({
|
1031
1038
|
href: href,
|
1039
|
+
openInNewTab: openInNewTab,
|
1032
1040
|
top: linkRect.bottom - outerRect.top + 10,
|
1033
1041
|
left: linkRect.left - outerRect.left
|
1034
1042
|
});
|
@@ -1047,18 +1055,19 @@ function LinkTooltipProvider(_ref) {
|
|
1047
1055
|
}
|
1048
1056
|
};
|
1049
1057
|
}, []);
|
1050
|
-
return /*#__PURE__*/React.createElement(
|
1051
|
-
value: disabled
|
1052
|
-
}, /*#__PURE__*/React.createElement(StateContext.Provider, {
|
1053
|
-
value: state
|
1054
|
-
}, /*#__PURE__*/React.createElement(UpdateContext.Provider, {
|
1058
|
+
return /*#__PURE__*/React.createElement(UpdateContext.Provider, {
|
1055
1059
|
value: update
|
1056
1060
|
}, /*#__PURE__*/React.createElement("div", {
|
1057
1061
|
ref: outerRef
|
1058
|
-
}, /*#__PURE__*/React.createElement(LinkTooltip,
|
1062
|
+
}, /*#__PURE__*/React.createElement(LinkTooltip, {
|
1063
|
+
editor: editor,
|
1064
|
+
state: state,
|
1065
|
+
disabled: disabled
|
1066
|
+
}), children));
|
1059
1067
|
}
|
1060
1068
|
function LinkPreview(_ref2) {
|
1061
1069
|
var href = _ref2.href,
|
1070
|
+
openInNewTab = _ref2.openInNewTab,
|
1062
1071
|
children = _ref2.children;
|
1063
1072
|
|
1064
1073
|
var _useContext = useContext(UpdateContext),
|
@@ -1069,22 +1078,21 @@ function LinkPreview(_ref2) {
|
|
1069
1078
|
return /*#__PURE__*/React.createElement("span", {
|
1070
1079
|
ref: ref,
|
1071
1080
|
onMouseEnter: function onMouseEnter() {
|
1072
|
-
return activate(href, ref);
|
1081
|
+
return activate(href, openInNewTab, ref);
|
1073
1082
|
},
|
1074
1083
|
onMouseLeave: deactivate,
|
1075
1084
|
onMouseDown: deactivate
|
1076
1085
|
}, children);
|
1077
1086
|
}
|
1078
|
-
function LinkTooltip() {
|
1079
|
-
var
|
1080
|
-
|
1087
|
+
function LinkTooltip(_ref3) {
|
1088
|
+
var editor = _ref3.editor,
|
1089
|
+
disabled = _ref3.disabled,
|
1090
|
+
state = _ref3.state;
|
1081
1091
|
|
1082
1092
|
var _useContext2 = useContext(UpdateContext),
|
1083
1093
|
keep = _useContext2.keep,
|
1084
1094
|
deactivate = _useContext2.deactivate;
|
1085
1095
|
|
1086
|
-
var editor = useSlate();
|
1087
|
-
|
1088
1096
|
if (disabled || !state || editor.selection && !Range.isCollapsed(editor.selection)) {
|
1089
1097
|
return null;
|
1090
1098
|
}
|
@@ -1098,14 +1106,95 @@ function LinkTooltip() {
|
|
1098
1106
|
left: state.left,
|
1099
1107
|
opacity: 1
|
1100
1108
|
}
|
1101
|
-
}, /*#__PURE__*/React.createElement(
|
1109
|
+
}, /*#__PURE__*/React.createElement(LinkDestination, {
|
1102
1110
|
href: state.href,
|
1111
|
+
openInNewTab: state.openInNewTab
|
1112
|
+
}));
|
1113
|
+
}
|
1114
|
+
|
1115
|
+
function LinkDestination(_ref4) {
|
1116
|
+
var href = _ref4.href,
|
1117
|
+
openInNewTab = _ref4.openInNewTab;
|
1118
|
+
|
1119
|
+
if (href === null || href === void 0 ? void 0 : href.chapter) {
|
1120
|
+
return /*#__PURE__*/React.createElement(ChapterLinkDestination, {
|
1121
|
+
permaId: href.chapter
|
1122
|
+
});
|
1123
|
+
} else if (href === null || href === void 0 ? void 0 : href.section) {
|
1124
|
+
return /*#__PURE__*/React.createElement(SectionLinkDestination, {
|
1125
|
+
permaId: href.section
|
1126
|
+
});
|
1127
|
+
} else {
|
1128
|
+
return /*#__PURE__*/React.createElement(ExternalLinkDestination, {
|
1129
|
+
href: href,
|
1130
|
+
openInNewTab: openInNewTab
|
1131
|
+
});
|
1132
|
+
}
|
1133
|
+
}
|
1134
|
+
|
1135
|
+
function ChapterLinkDestination(_ref5) {
|
1136
|
+
var permaId = _ref5.permaId;
|
1137
|
+
var chapter = useChapter({
|
1138
|
+
permaId: permaId
|
1139
|
+
});
|
1140
|
+
|
1141
|
+
var _useI18n = useI18n({
|
1142
|
+
locale: 'ui'
|
1143
|
+
}),
|
1144
|
+
t = _useI18n.t;
|
1145
|
+
|
1146
|
+
if (!chapter) {
|
1147
|
+
return '(Deleted chapter)';
|
1148
|
+
}
|
1149
|
+
|
1150
|
+
return /*#__PURE__*/React.createElement("a", {
|
1151
|
+
href: "#".concat(chapter.chapterSlug),
|
1152
|
+
title: t('pageflow_scrolled.inline_editing.link_tooltip.visit_chapter')
|
1153
|
+
}, /*#__PURE__*/React.createElement("span", {
|
1154
|
+
className: styles$7.linkTooltipChapterNumber
|
1155
|
+
}, t('pageflow_scrolled.inline_editing.link_tooltip.chapter_number', {
|
1156
|
+
number: chapter.index + 1
|
1157
|
+
})), " ", chapter.title);
|
1158
|
+
}
|
1159
|
+
|
1160
|
+
function SectionLinkDestination(_ref6) {
|
1161
|
+
var permaId = _ref6.permaId;
|
1162
|
+
|
1163
|
+
var _useI18n2 = useI18n({
|
1164
|
+
locale: 'ui'
|
1165
|
+
}),
|
1166
|
+
t = _useI18n2.t;
|
1167
|
+
|
1168
|
+
return /*#__PURE__*/React.createElement("div", {
|
1169
|
+
className: styles$7.linkTooltipThumbnail
|
1170
|
+
}, /*#__PURE__*/React.createElement(SectionThumbnail, {
|
1171
|
+
sectionPermaId: permaId
|
1172
|
+
}), /*#__PURE__*/React.createElement("a", {
|
1173
|
+
href: "#section-".concat(permaId),
|
1174
|
+
className: styles$7.linkTooltipThumbnailClickMask,
|
1175
|
+
title: t('pageflow_scrolled.inline_editing.link_tooltip.visit_section')
|
1176
|
+
}));
|
1177
|
+
}
|
1178
|
+
|
1179
|
+
function ExternalLinkDestination(_ref7) {
|
1180
|
+
var href = _ref7.href,
|
1181
|
+
openInNewTab = _ref7.openInNewTab;
|
1182
|
+
|
1183
|
+
var _useI18n3 = useI18n({
|
1184
|
+
locale: 'ui'
|
1185
|
+
}),
|
1186
|
+
t = _useI18n3.t;
|
1187
|
+
|
1188
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("a", {
|
1189
|
+
href: href,
|
1103
1190
|
target: "_blank",
|
1104
1191
|
rel: "noopener noreferrer"
|
1105
|
-
},
|
1192
|
+
}, href, /*#__PURE__*/React.createElement(ExternalLinkIcon, {
|
1106
1193
|
width: 10,
|
1107
1194
|
height: 10
|
1108
|
-
}))
|
1195
|
+
})), /*#__PURE__*/React.createElement("div", {
|
1196
|
+
className: styles$7.linkTooltipNewTab
|
1197
|
+
}, openInNewTab ? t('pageflow_scrolled.inline_editing.link_tooltip.opens_in_new_tab') : t('pageflow_scrolled.inline_editing.link_tooltip.opens_in_same_tab')));
|
1109
1198
|
}
|
1110
1199
|
|
1111
1200
|
function withLinks(editor) {
|
@@ -1120,50 +1209,13 @@ function withLinks(editor) {
|
|
1120
1209
|
function renderElementWithLinkPreview(options) {
|
1121
1210
|
if (options.element.type === 'link') {
|
1122
1211
|
return /*#__PURE__*/React.createElement(LinkPreview, {
|
1123
|
-
href: options.element.href
|
1212
|
+
href: options.element.href,
|
1213
|
+
openInNewTab: options.element.openInNewTab
|
1124
1214
|
}, renderElement(options));
|
1125
1215
|
} else {
|
1126
1216
|
return renderElement(options);
|
1127
1217
|
}
|
1128
1218
|
}
|
1129
|
-
function renderLeafWithLinkSelection(options) {
|
1130
|
-
if (options.leaf.linkSelection) {
|
1131
|
-
return /*#__PURE__*/React.createElement("span", Object.assign({}, options.attributes, {
|
1132
|
-
style: {
|
1133
|
-
backgroundColor: '#aaa'
|
1134
|
-
}
|
1135
|
-
}), renderLeaf$1(options));
|
1136
|
-
}
|
1137
|
-
|
1138
|
-
return renderLeaf$1(options);
|
1139
|
-
}
|
1140
|
-
function decorateLinkSelection(_ref, linkSelection) {
|
1141
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
1142
|
-
node = _ref2[0],
|
1143
|
-
path = _ref2[1];
|
1144
|
-
|
1145
|
-
if (linkSelection && Text.isText(node)) {
|
1146
|
-
var nodeRange = {
|
1147
|
-
anchor: {
|
1148
|
-
path: path,
|
1149
|
-
offset: 0
|
1150
|
-
},
|
1151
|
-
focus: {
|
1152
|
-
path: path,
|
1153
|
-
offset: node.text.length
|
1154
|
-
}
|
1155
|
-
};
|
1156
|
-
var intersection = Range.intersection(nodeRange, linkSelection);
|
1157
|
-
|
1158
|
-
if (intersection) {
|
1159
|
-
return [_objectSpread2(_objectSpread2({}, intersection), {}, {
|
1160
|
-
linkSelection: true
|
1161
|
-
})];
|
1162
|
-
}
|
1163
|
-
}
|
1164
|
-
|
1165
|
-
return [];
|
1166
|
-
}
|
1167
1219
|
|
1168
1220
|
// element is currently being dragged over the element. `react-dnd`
|
1169
1221
|
// causes "Update on unmounted component warning" when dropping an
|
@@ -1206,105 +1258,29 @@ function useDropTargetsActive() {
|
|
1206
1258
|
return [dropTargetsActive, drop];
|
1207
1259
|
}
|
1208
1260
|
|
1209
|
-
function
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1261
|
+
function useSelectLinkDestination() {
|
1262
|
+
return function () {
|
1263
|
+
return new Promise(function (resolve, reject) {
|
1264
|
+
postSelectLinkDestinationMessage();
|
1265
|
+
window.addEventListener('message', receive);
|
1266
|
+
|
1267
|
+
function receive(message) {
|
1268
|
+
if (window.location.href.indexOf(message.origin) === 0) {
|
1269
|
+
if (message.data.type === 'LINK_DESTINATION_SELECTED') {
|
1270
|
+
window.removeEventListener('message', receive);
|
1271
|
+
resolve(message.data.payload);
|
1272
|
+
} else if (message.data.type === 'LINK_DESTINATION_SELECTION_ABORTED') {
|
1273
|
+
window.removeEventListener('message', receive);
|
1274
|
+
reject();
|
1275
|
+
}
|
1217
1276
|
}
|
1218
1277
|
}
|
1219
|
-
}
|
1220
|
-
|
1221
|
-
return target;
|
1278
|
+
});
|
1222
1279
|
};
|
1223
|
-
|
1224
|
-
return _extends$4.apply(this, arguments);
|
1225
|
-
}
|
1226
|
-
var CancelIcon = (function (_ref) {
|
1227
|
-
var _ref$styles = _ref.styles,
|
1228
|
-
styles = _ref$styles === void 0 ? {} : _ref$styles,
|
1229
|
-
props = _objectWithoutProperties(_ref, ["styles"]);
|
1230
|
-
|
1231
|
-
return /*#__PURE__*/React.createElement("svg", _extends$4({
|
1232
|
-
"aria-hidden": "true",
|
1233
|
-
"data-prefix": "fas",
|
1234
|
-
"data-icon": "times",
|
1235
|
-
className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-times"] || "fa-times") + " " + (styles["fa-w-11"] || "fa-w-11"),
|
1236
|
-
xmlns: "http://www.w3.org/2000/svg",
|
1237
|
-
viewBox: "0 0 352 512"
|
1238
|
-
}, props), /*#__PURE__*/React.createElement("path", {
|
1239
|
-
fill: "currentColor",
|
1240
|
-
d: "M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"
|
1241
|
-
}));
|
1242
|
-
});
|
1243
|
-
|
1244
|
-
function LinkInput(_ref) {
|
1245
|
-
var onSubmit = _ref.onSubmit,
|
1246
|
-
onCancel = _ref.onCancel;
|
1247
|
-
|
1248
|
-
var _useI18n = useI18n({
|
1249
|
-
locale: 'ui'
|
1250
|
-
}),
|
1251
|
-
t = _useI18n.t;
|
1252
|
-
|
1253
|
-
var _useState = useState(''),
|
1254
|
-
_useState2 = _slicedToArray(_useState, 2),
|
1255
|
-
href = _useState2[0],
|
1256
|
-
setHref = _useState2[1];
|
1257
|
-
|
1258
|
-
var ref = useRef(); // With useEffect the deselect in HoveringToolbar/handleButtonClick breaks focusing.
|
1259
|
-
|
1260
|
-
useLayoutEffect(function () {
|
1261
|
-
ref.current.focus();
|
1262
|
-
}, []);
|
1263
|
-
|
1264
|
-
function handleKey(event) {
|
1265
|
-
if (event.key === 'Enter') {
|
1266
|
-
event.preventDefault();
|
1267
|
-
ref.current.blur();
|
1268
|
-
} else if (event.key === 'Escape') {
|
1269
|
-
event.preventDefault();
|
1270
|
-
onCancel();
|
1271
|
-
}
|
1272
|
-
}
|
1273
|
-
|
1274
|
-
function submit() {
|
1275
|
-
if (href) {
|
1276
|
-
onSubmit(href);
|
1277
|
-
} else {
|
1278
|
-
onCancel();
|
1279
|
-
}
|
1280
|
-
}
|
1281
|
-
|
1282
|
-
return /*#__PURE__*/React.createElement("div", {
|
1283
|
-
className: styles$7.linkTooltip
|
1284
|
-
}, /*#__PURE__*/React.createElement("input", {
|
1285
|
-
ref: ref,
|
1286
|
-
type: "text",
|
1287
|
-
value: href,
|
1288
|
-
placeholder: t('pageflow_scrolled.inline_editing.url_placeholder'),
|
1289
|
-
onBlur: submit,
|
1290
|
-
onChange: function onChange(e) {
|
1291
|
-
return setHref(e.target.value);
|
1292
|
-
},
|
1293
|
-
onKeyDown: handleKey
|
1294
|
-
}), /*#__PURE__*/React.createElement("button", {
|
1295
|
-
onMouseDown: function onMouseDown(e) {
|
1296
|
-
return e.preventDefault();
|
1297
|
-
},
|
1298
|
-
onClick: onCancel,
|
1299
|
-
title: t('pageflow_scrolled.inline_editing.cancel')
|
1300
|
-
}, /*#__PURE__*/React.createElement(CancelIcon, {
|
1301
|
-
width: 10,
|
1302
|
-
height: 10
|
1303
|
-
})));
|
1304
1280
|
}
|
1305
1281
|
|
1306
|
-
function _extends$
|
1307
|
-
_extends$
|
1282
|
+
function _extends$4() {
|
1283
|
+
_extends$4 = Object.assign || function (target) {
|
1308
1284
|
for (var i = 1; i < arguments.length; i++) {
|
1309
1285
|
var source = arguments[i];
|
1310
1286
|
|
@@ -1318,14 +1294,14 @@ function _extends$5() {
|
|
1318
1294
|
return target;
|
1319
1295
|
};
|
1320
1296
|
|
1321
|
-
return _extends$
|
1297
|
+
return _extends$4.apply(this, arguments);
|
1322
1298
|
}
|
1323
1299
|
var BoldIcon = (function (_ref) {
|
1324
1300
|
var _ref$styles = _ref.styles,
|
1325
1301
|
styles = _ref$styles === void 0 ? {} : _ref$styles,
|
1326
1302
|
props = _objectWithoutProperties(_ref, ["styles"]);
|
1327
1303
|
|
1328
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
1304
|
+
return /*#__PURE__*/React.createElement("svg", _extends$4({
|
1329
1305
|
"aria-hidden": "true",
|
1330
1306
|
"data-prefix": "fas",
|
1331
1307
|
"data-icon": "bold",
|
@@ -1338,8 +1314,8 @@ var BoldIcon = (function (_ref) {
|
|
1338
1314
|
}));
|
1339
1315
|
});
|
1340
1316
|
|
1341
|
-
function _extends$
|
1342
|
-
_extends$
|
1317
|
+
function _extends$5() {
|
1318
|
+
_extends$5 = Object.assign || function (target) {
|
1343
1319
|
for (var i = 1; i < arguments.length; i++) {
|
1344
1320
|
var source = arguments[i];
|
1345
1321
|
|
@@ -1353,14 +1329,14 @@ function _extends$6() {
|
|
1353
1329
|
return target;
|
1354
1330
|
};
|
1355
1331
|
|
1356
|
-
return _extends$
|
1332
|
+
return _extends$5.apply(this, arguments);
|
1357
1333
|
}
|
1358
1334
|
var UnderlineIcon = (function (_ref) {
|
1359
1335
|
var _ref$styles = _ref.styles,
|
1360
1336
|
styles = _ref$styles === void 0 ? {} : _ref$styles,
|
1361
1337
|
props = _objectWithoutProperties(_ref, ["styles"]);
|
1362
1338
|
|
1363
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
1339
|
+
return /*#__PURE__*/React.createElement("svg", _extends$5({
|
1364
1340
|
"aria-hidden": "true",
|
1365
1341
|
"data-prefix": "fas",
|
1366
1342
|
"data-icon": "underline",
|
@@ -1373,8 +1349,8 @@ var UnderlineIcon = (function (_ref) {
|
|
1373
1349
|
}));
|
1374
1350
|
});
|
1375
1351
|
|
1376
|
-
function _extends$
|
1377
|
-
_extends$
|
1352
|
+
function _extends$6() {
|
1353
|
+
_extends$6 = Object.assign || function (target) {
|
1378
1354
|
for (var i = 1; i < arguments.length; i++) {
|
1379
1355
|
var source = arguments[i];
|
1380
1356
|
|
@@ -1388,14 +1364,14 @@ function _extends$7() {
|
|
1388
1364
|
return target;
|
1389
1365
|
};
|
1390
1366
|
|
1391
|
-
return _extends$
|
1367
|
+
return _extends$6.apply(this, arguments);
|
1392
1368
|
}
|
1393
1369
|
var ItalicIcon = (function (_ref) {
|
1394
1370
|
var _ref$styles = _ref.styles,
|
1395
1371
|
styles = _ref$styles === void 0 ? {} : _ref$styles,
|
1396
1372
|
props = _objectWithoutProperties(_ref, ["styles"]);
|
1397
1373
|
|
1398
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
1374
|
+
return /*#__PURE__*/React.createElement("svg", _extends$6({
|
1399
1375
|
"aria-hidden": "true",
|
1400
1376
|
"data-prefix": "fas",
|
1401
1377
|
"data-icon": "italic",
|
@@ -1408,8 +1384,8 @@ var ItalicIcon = (function (_ref) {
|
|
1408
1384
|
}));
|
1409
1385
|
});
|
1410
1386
|
|
1411
|
-
function _extends$
|
1412
|
-
_extends$
|
1387
|
+
function _extends$7() {
|
1388
|
+
_extends$7 = Object.assign || function (target) {
|
1413
1389
|
for (var i = 1; i < arguments.length; i++) {
|
1414
1390
|
var source = arguments[i];
|
1415
1391
|
|
@@ -1423,14 +1399,14 @@ function _extends$8() {
|
|
1423
1399
|
return target;
|
1424
1400
|
};
|
1425
1401
|
|
1426
|
-
return _extends$
|
1402
|
+
return _extends$7.apply(this, arguments);
|
1427
1403
|
}
|
1428
1404
|
var StrikethroughIcon = (function (_ref) {
|
1429
1405
|
var _ref$styles = _ref.styles,
|
1430
1406
|
styles = _ref$styles === void 0 ? {} : _ref$styles,
|
1431
1407
|
props = _objectWithoutProperties(_ref, ["styles"]);
|
1432
1408
|
|
1433
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
1409
|
+
return /*#__PURE__*/React.createElement("svg", _extends$7({
|
1434
1410
|
"aria-hidden": "true",
|
1435
1411
|
"data-prefix": "fas",
|
1436
1412
|
"data-icon": "strikethrough",
|
@@ -1443,8 +1419,8 @@ var StrikethroughIcon = (function (_ref) {
|
|
1443
1419
|
}));
|
1444
1420
|
});
|
1445
1421
|
|
1446
|
-
function _extends$
|
1447
|
-
_extends$
|
1422
|
+
function _extends$8() {
|
1423
|
+
_extends$8 = Object.assign || function (target) {
|
1448
1424
|
for (var i = 1; i < arguments.length; i++) {
|
1449
1425
|
var source = arguments[i];
|
1450
1426
|
|
@@ -1458,14 +1434,14 @@ function _extends$9() {
|
|
1458
1434
|
return target;
|
1459
1435
|
};
|
1460
1436
|
|
1461
|
-
return _extends$
|
1437
|
+
return _extends$8.apply(this, arguments);
|
1462
1438
|
}
|
1463
1439
|
var LinkIcon = (function (_ref) {
|
1464
1440
|
var _ref$styles = _ref.styles,
|
1465
1441
|
styles = _ref$styles === void 0 ? {} : _ref$styles,
|
1466
1442
|
props = _objectWithoutProperties(_ref, ["styles"]);
|
1467
1443
|
|
1468
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
1444
|
+
return /*#__PURE__*/React.createElement("svg", _extends$8({
|
1469
1445
|
"aria-hidden": "true",
|
1470
1446
|
"data-prefix": "fas",
|
1471
1447
|
"data-icon": "link",
|
@@ -1478,9 +1454,7 @@ var LinkIcon = (function (_ref) {
|
|
1478
1454
|
}));
|
1479
1455
|
});
|
1480
1456
|
|
1481
|
-
function HoveringToolbar(
|
1482
|
-
var linkSelection = _ref.linkSelection,
|
1483
|
-
setLinkSelection = _ref.setLinkSelection;
|
1457
|
+
function HoveringToolbar() {
|
1484
1458
|
var ref = useRef();
|
1485
1459
|
var outerRef = useRef();
|
1486
1460
|
var editor = useSlate();
|
@@ -1490,11 +1464,12 @@ function HoveringToolbar(_ref) {
|
|
1490
1464
|
}),
|
1491
1465
|
t = _useI18n.t;
|
1492
1466
|
|
1467
|
+
var selectLinkDestination = useSelectLinkDestination();
|
1493
1468
|
useEffect(function () {
|
1494
1469
|
var el = ref.current;
|
1495
1470
|
var selection = editor.selection;
|
1496
1471
|
|
1497
|
-
if (!el || !outerRef.current
|
1472
|
+
if (!el || !outerRef.current) {
|
1498
1473
|
return;
|
1499
1474
|
}
|
1500
1475
|
|
@@ -1515,10 +1490,10 @@ function HoveringToolbar(_ref) {
|
|
1515
1490
|
}, /*#__PURE__*/React.createElement("div", {
|
1516
1491
|
ref: ref,
|
1517
1492
|
className: styles$7.hoveringToolbar
|
1518
|
-
},
|
1493
|
+
}, renderToolbar$1(editor, t, selectLinkDestination)));
|
1519
1494
|
}
|
1520
1495
|
|
1521
|
-
function renderToolbar$1(editor,
|
1496
|
+
function renderToolbar$1(editor, t, selectLinkDestination) {
|
1522
1497
|
var buttons = [{
|
1523
1498
|
name: 'bold',
|
1524
1499
|
text: t('pageflow_scrolled.inline_editing.formats.bold'),
|
@@ -1547,21 +1522,21 @@ function renderToolbar$1(editor, setLinkSelection, t) {
|
|
1547
1522
|
return /*#__PURE__*/React.createElement(Toolbar, {
|
1548
1523
|
buttons: buttons,
|
1549
1524
|
onButtonClick: function onButtonClick(name) {
|
1550
|
-
return handleButtonClick(editor, name,
|
1525
|
+
return handleButtonClick(editor, name, selectLinkDestination);
|
1551
1526
|
}
|
1552
1527
|
});
|
1553
1528
|
}
|
1554
1529
|
|
1555
|
-
function handleButtonClick(editor, format,
|
1530
|
+
function handleButtonClick(editor, format, selectLinkDestination) {
|
1556
1531
|
if (format === 'link') {
|
1557
1532
|
if (isLinkActive(editor)) {
|
1558
1533
|
unwrapLink(editor);
|
1559
1534
|
} else {
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1535
|
+
selectLinkDestination().then(function (_ref) {
|
1536
|
+
var href = _ref.href,
|
1537
|
+
openInNewTab = _ref.openInNewTab;
|
1538
|
+
wrapLink(editor, href, openInNewTab);
|
1539
|
+
}, function () {});
|
1565
1540
|
}
|
1566
1541
|
} else {
|
1567
1542
|
toggleMark(editor, format);
|
@@ -1576,26 +1551,6 @@ function isButtonActive(editor, format) {
|
|
1576
1551
|
}
|
1577
1552
|
}
|
1578
1553
|
|
1579
|
-
function renderLinkInput(editor, linkSelection, setLinkSelection) {
|
1580
|
-
function handleSubmit(href) {
|
1581
|
-
Transforms.select(editor, linkSelection);
|
1582
|
-
ReactEditor.focus(editor);
|
1583
|
-
wrapLink(editor, href);
|
1584
|
-
setLinkSelection(null);
|
1585
|
-
}
|
1586
|
-
|
1587
|
-
function handleCancel() {
|
1588
|
-
setLinkSelection(null);
|
1589
|
-
Transforms.select(editor, linkSelection);
|
1590
|
-
ReactEditor.focus(editor);
|
1591
|
-
}
|
1592
|
-
|
1593
|
-
return /*#__PURE__*/React.createElement(LinkInput, {
|
1594
|
-
onSubmit: handleSubmit,
|
1595
|
-
onCancel: handleCancel
|
1596
|
-
});
|
1597
|
-
}
|
1598
|
-
|
1599
1554
|
function unwrapLink(editor) {
|
1600
1555
|
Transforms.unwrapNodes(editor, {
|
1601
1556
|
match: function match(n) {
|
@@ -1604,10 +1559,11 @@ function unwrapLink(editor) {
|
|
1604
1559
|
});
|
1605
1560
|
}
|
1606
1561
|
|
1607
|
-
function wrapLink(editor, href) {
|
1562
|
+
function wrapLink(editor, href, openInNewTab) {
|
1608
1563
|
var link = {
|
1609
1564
|
type: 'link',
|
1610
1565
|
href: href,
|
1566
|
+
openInNewTab: openInNewTab,
|
1611
1567
|
children: []
|
1612
1568
|
};
|
1613
1569
|
Transforms.wrapNodes(editor, link, {
|
@@ -1645,7 +1601,7 @@ function isMarkActive(editor, format) {
|
|
1645
1601
|
return marks ? marks[format] === true : false;
|
1646
1602
|
}
|
1647
1603
|
|
1648
|
-
function
|
1604
|
+
function getUniformSelectedNode(editor, propertyName) {
|
1649
1605
|
var currentNodeEntries = _toConsumableArray(Editor.nodes(editor, {
|
1650
1606
|
match: function match(n) {
|
1651
1607
|
return !!n.type;
|
@@ -1661,11 +1617,222 @@ function getUniformSelectedNodeProperty(editor, propertyName) {
|
|
1661
1617
|
return node[propertyName];
|
1662
1618
|
})));
|
1663
1619
|
|
1664
|
-
return values.length === 1 ?
|
1620
|
+
return values.length === 1 ? currentNodeEntries[0][0] : null;
|
1665
1621
|
}
|
1666
1622
|
|
1667
|
-
function
|
1668
|
-
|
1623
|
+
function _createForOfIteratorHelper(o) {
|
1624
|
+
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
|
1625
|
+
if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) {
|
1626
|
+
var i = 0;
|
1627
|
+
|
1628
|
+
var F = function F() {};
|
1629
|
+
|
1630
|
+
return {
|
1631
|
+
s: F,
|
1632
|
+
n: function n() {
|
1633
|
+
if (i >= o.length) return {
|
1634
|
+
done: true
|
1635
|
+
};
|
1636
|
+
return {
|
1637
|
+
done: false,
|
1638
|
+
value: o[i++]
|
1639
|
+
};
|
1640
|
+
},
|
1641
|
+
e: function e(_e) {
|
1642
|
+
throw _e;
|
1643
|
+
},
|
1644
|
+
f: F
|
1645
|
+
};
|
1646
|
+
}
|
1647
|
+
|
1648
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
1649
|
+
}
|
1650
|
+
|
1651
|
+
var it,
|
1652
|
+
normalCompletion = true,
|
1653
|
+
didErr = false,
|
1654
|
+
err;
|
1655
|
+
return {
|
1656
|
+
s: function s() {
|
1657
|
+
it = o[Symbol.iterator]();
|
1658
|
+
},
|
1659
|
+
n: function n() {
|
1660
|
+
var step = it.next();
|
1661
|
+
normalCompletion = step.done;
|
1662
|
+
return step;
|
1663
|
+
},
|
1664
|
+
e: function e(_e2) {
|
1665
|
+
didErr = true;
|
1666
|
+
err = _e2;
|
1667
|
+
},
|
1668
|
+
f: function f() {
|
1669
|
+
try {
|
1670
|
+
if (!normalCompletion && it["return"] != null) it["return"]();
|
1671
|
+
} finally {
|
1672
|
+
if (didErr) throw err;
|
1673
|
+
}
|
1674
|
+
}
|
1675
|
+
};
|
1676
|
+
}
|
1677
|
+
|
1678
|
+
function isBlockActive(editor, format) {
|
1679
|
+
var _Editor$nodes = Editor.nodes(editor, {
|
1680
|
+
match: function match(n) {
|
1681
|
+
return n.type === format;
|
1682
|
+
}
|
1683
|
+
}),
|
1684
|
+
_Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
|
1685
|
+
match = _Editor$nodes2[0];
|
1686
|
+
|
1687
|
+
return !!match;
|
1688
|
+
}
|
1689
|
+
var listTypes = ['numbered-list', 'bulleted-list'];
|
1690
|
+
function toggleBlock(editor, format) {
|
1691
|
+
var isActive = isBlockActive(editor, format);
|
1692
|
+
var isList = listTypes.includes(format);
|
1693
|
+
Transforms.unwrapNodes(editor, {
|
1694
|
+
match: function match(n) {
|
1695
|
+
return listTypes.includes(n.type);
|
1696
|
+
},
|
1697
|
+
split: true
|
1698
|
+
});
|
1699
|
+
Transforms.setNodes(editor, {
|
1700
|
+
type: isActive ? 'paragraph' : isList ? 'list-item' : format
|
1701
|
+
});
|
1702
|
+
|
1703
|
+
if (!isActive && isList) {
|
1704
|
+
var block = _objectSpread2({
|
1705
|
+
type: format,
|
1706
|
+
children: []
|
1707
|
+
}, preserveTypograpyhVariant(editor));
|
1708
|
+
|
1709
|
+
Transforms.wrapNodes(editor, block);
|
1710
|
+
}
|
1711
|
+
}
|
1712
|
+
function applyTypograpyhVariant(editor, variant) {
|
1713
|
+
Transforms.setNodes(editor, {
|
1714
|
+
variant: variant
|
1715
|
+
}, {
|
1716
|
+
mode: 'highest'
|
1717
|
+
});
|
1718
|
+
applyTypograpyhVariantToListItems(editor, variant);
|
1719
|
+
}
|
1720
|
+
|
1721
|
+
function applyTypograpyhVariantToListItems(editor, variant) {
|
1722
|
+
var lists = Editor.nodes(editor, {
|
1723
|
+
match: function match(n) {
|
1724
|
+
return listTypes.includes(n.type);
|
1725
|
+
}
|
1726
|
+
});
|
1727
|
+
|
1728
|
+
var _iterator = _createForOfIteratorHelper(lists),
|
1729
|
+
_step;
|
1730
|
+
|
1731
|
+
try {
|
1732
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
1733
|
+
var _step$value = _slicedToArray(_step.value, 2),
|
1734
|
+
listPath = _step$value[1];
|
1735
|
+
|
1736
|
+
var items = Editor.nodes(editor, {
|
1737
|
+
at: listPath,
|
1738
|
+
match: function match(n) {
|
1739
|
+
return n.type === 'list-item';
|
1740
|
+
}
|
1741
|
+
});
|
1742
|
+
|
1743
|
+
var _iterator2 = _createForOfIteratorHelper(items),
|
1744
|
+
_step2;
|
1745
|
+
|
1746
|
+
try {
|
1747
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
1748
|
+
var _step2$value = _slicedToArray(_step2.value, 2),
|
1749
|
+
itemPath = _step2$value[1];
|
1750
|
+
|
1751
|
+
Transforms.setNodes(editor, {
|
1752
|
+
variant: variant
|
1753
|
+
}, {
|
1754
|
+
at: itemPath
|
1755
|
+
});
|
1756
|
+
}
|
1757
|
+
} catch (err) {
|
1758
|
+
_iterator2.e(err);
|
1759
|
+
} finally {
|
1760
|
+
_iterator2.f();
|
1761
|
+
}
|
1762
|
+
}
|
1763
|
+
} catch (err) {
|
1764
|
+
_iterator.e(err);
|
1765
|
+
} finally {
|
1766
|
+
_iterator.f();
|
1767
|
+
}
|
1768
|
+
}
|
1769
|
+
|
1770
|
+
function preserveTypograpyhVariant(editor) {
|
1771
|
+
var nodeEntry = Editor.above(editor, {
|
1772
|
+
at: Range.start(editor.selection),
|
1773
|
+
match: function match(n) {
|
1774
|
+
return !!n.type;
|
1775
|
+
}
|
1776
|
+
});
|
1777
|
+
return nodeEntry && nodeEntry[0].variant ? {
|
1778
|
+
variant: nodeEntry[0].variant
|
1779
|
+
} : {};
|
1780
|
+
}
|
1781
|
+
|
1782
|
+
function withBlockNormalization(_ref, editor) {
|
1783
|
+
var onlyParagraphs = _ref.onlyParagraphs;
|
1784
|
+
|
1785
|
+
if (!onlyParagraphs) {
|
1786
|
+
return editor;
|
1787
|
+
}
|
1788
|
+
|
1789
|
+
var normalizeNode = editor.normalizeNode;
|
1790
|
+
|
1791
|
+
editor.normalizeNode = function (_ref2) {
|
1792
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
1793
|
+
node = _ref3[0],
|
1794
|
+
path = _ref3[1];
|
1795
|
+
|
1796
|
+
if (path.length === 0) {
|
1797
|
+
var _iterator3 = _createForOfIteratorHelper(Node.children(editor, path)),
|
1798
|
+
_step3;
|
1799
|
+
|
1800
|
+
try {
|
1801
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
1802
|
+
var _step3$value = _slicedToArray(_step3.value, 2),
|
1803
|
+
child = _step3$value[0],
|
1804
|
+
childPath = _step3$value[1];
|
1805
|
+
|
1806
|
+
if (Element.isElement(child) && child.type !== 'paragraph') {
|
1807
|
+
Transforms.unwrapNodes(editor, {
|
1808
|
+
match: function match(n) {
|
1809
|
+
return listTypes.includes(n.type);
|
1810
|
+
},
|
1811
|
+
split: true,
|
1812
|
+
at: childPath
|
1813
|
+
});
|
1814
|
+
Transforms.setNodes(editor, {
|
1815
|
+
type: 'paragraph'
|
1816
|
+
}, {
|
1817
|
+
at: childPath
|
1818
|
+
});
|
1819
|
+
}
|
1820
|
+
}
|
1821
|
+
} catch (err) {
|
1822
|
+
_iterator3.e(err);
|
1823
|
+
} finally {
|
1824
|
+
_iterator3.f();
|
1825
|
+
}
|
1826
|
+
}
|
1827
|
+
|
1828
|
+
return normalizeNode([node, path]);
|
1829
|
+
};
|
1830
|
+
|
1831
|
+
return editor;
|
1832
|
+
}
|
1833
|
+
|
1834
|
+
function _extends$9() {
|
1835
|
+
_extends$9 = Object.assign || function (target) {
|
1669
1836
|
for (var i = 1; i < arguments.length; i++) {
|
1670
1837
|
var source = arguments[i];
|
1671
1838
|
|
@@ -1679,14 +1846,14 @@ function _extends$a() {
|
|
1679
1846
|
return target;
|
1680
1847
|
};
|
1681
1848
|
|
1682
|
-
return _extends$
|
1849
|
+
return _extends$9.apply(this, arguments);
|
1683
1850
|
}
|
1684
1851
|
var TextIcon = (function (_ref) {
|
1685
1852
|
var _ref$styles = _ref.styles,
|
1686
1853
|
styles = _ref$styles === void 0 ? {} : _ref$styles,
|
1687
1854
|
props = _objectWithoutProperties(_ref, ["styles"]);
|
1688
1855
|
|
1689
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
1856
|
+
return /*#__PURE__*/React.createElement("svg", _extends$9({
|
1690
1857
|
"aria-hidden": "true",
|
1691
1858
|
"data-prefix": "fas",
|
1692
1859
|
"data-icon": "align-justify",
|
@@ -1699,8 +1866,8 @@ var TextIcon = (function (_ref) {
|
|
1699
1866
|
}));
|
1700
1867
|
});
|
1701
1868
|
|
1702
|
-
function _extends$
|
1703
|
-
_extends$
|
1869
|
+
function _extends$a() {
|
1870
|
+
_extends$a = Object.assign || function (target) {
|
1704
1871
|
for (var i = 1; i < arguments.length; i++) {
|
1705
1872
|
var source = arguments[i];
|
1706
1873
|
|
@@ -1714,14 +1881,14 @@ function _extends$b() {
|
|
1714
1881
|
return target;
|
1715
1882
|
};
|
1716
1883
|
|
1717
|
-
return _extends$
|
1884
|
+
return _extends$a.apply(this, arguments);
|
1718
1885
|
}
|
1719
1886
|
var HeadingIcon = (function (_ref) {
|
1720
1887
|
var _ref$styles = _ref.styles,
|
1721
1888
|
styles = _ref$styles === void 0 ? {} : _ref$styles,
|
1722
1889
|
props = _objectWithoutProperties(_ref, ["styles"]);
|
1723
1890
|
|
1724
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
1891
|
+
return /*#__PURE__*/React.createElement("svg", _extends$a({
|
1725
1892
|
"aria-hidden": "true",
|
1726
1893
|
"data-prefix": "fas",
|
1727
1894
|
"data-icon": "heading",
|
@@ -1734,8 +1901,8 @@ var HeadingIcon = (function (_ref) {
|
|
1734
1901
|
}));
|
1735
1902
|
});
|
1736
1903
|
|
1737
|
-
function _extends$
|
1738
|
-
_extends$
|
1904
|
+
function _extends$b() {
|
1905
|
+
_extends$b = Object.assign || function (target) {
|
1739
1906
|
for (var i = 1; i < arguments.length; i++) {
|
1740
1907
|
var source = arguments[i];
|
1741
1908
|
|
@@ -1749,14 +1916,14 @@ function _extends$c() {
|
|
1749
1916
|
return target;
|
1750
1917
|
};
|
1751
1918
|
|
1752
|
-
return _extends$
|
1919
|
+
return _extends$b.apply(this, arguments);
|
1753
1920
|
}
|
1754
1921
|
var OlIcon = (function (_ref) {
|
1755
1922
|
var _ref$styles = _ref.styles,
|
1756
1923
|
styles = _ref$styles === void 0 ? {} : _ref$styles,
|
1757
1924
|
props = _objectWithoutProperties(_ref, ["styles"]);
|
1758
1925
|
|
1759
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
1926
|
+
return /*#__PURE__*/React.createElement("svg", _extends$b({
|
1760
1927
|
"aria-hidden": "true",
|
1761
1928
|
"data-prefix": "fas",
|
1762
1929
|
"data-icon": "list-ol",
|
@@ -1769,8 +1936,8 @@ var OlIcon = (function (_ref) {
|
|
1769
1936
|
}));
|
1770
1937
|
});
|
1771
1938
|
|
1772
|
-
function _extends$
|
1773
|
-
_extends$
|
1939
|
+
function _extends$c() {
|
1940
|
+
_extends$c = Object.assign || function (target) {
|
1774
1941
|
for (var i = 1; i < arguments.length; i++) {
|
1775
1942
|
var source = arguments[i];
|
1776
1943
|
|
@@ -1784,14 +1951,14 @@ function _extends$d() {
|
|
1784
1951
|
return target;
|
1785
1952
|
};
|
1786
1953
|
|
1787
|
-
return _extends$
|
1954
|
+
return _extends$c.apply(this, arguments);
|
1788
1955
|
}
|
1789
1956
|
var UlIcon = (function (_ref) {
|
1790
1957
|
var _ref$styles = _ref.styles,
|
1791
1958
|
styles = _ref$styles === void 0 ? {} : _ref$styles,
|
1792
1959
|
props = _objectWithoutProperties(_ref, ["styles"]);
|
1793
1960
|
|
1794
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
1961
|
+
return /*#__PURE__*/React.createElement("svg", _extends$c({
|
1795
1962
|
"aria-hidden": "true",
|
1796
1963
|
"data-prefix": "fas",
|
1797
1964
|
"data-icon": "list-ul",
|
@@ -1804,8 +1971,8 @@ var UlIcon = (function (_ref) {
|
|
1804
1971
|
}));
|
1805
1972
|
});
|
1806
1973
|
|
1807
|
-
function _extends$
|
1808
|
-
_extends$
|
1974
|
+
function _extends$d() {
|
1975
|
+
_extends$d = Object.assign || function (target) {
|
1809
1976
|
for (var i = 1; i < arguments.length; i++) {
|
1810
1977
|
var source = arguments[i];
|
1811
1978
|
|
@@ -1819,14 +1986,14 @@ function _extends$e() {
|
|
1819
1986
|
return target;
|
1820
1987
|
};
|
1821
1988
|
|
1822
|
-
return _extends$
|
1989
|
+
return _extends$d.apply(this, arguments);
|
1823
1990
|
}
|
1824
1991
|
var QuoteIcon = (function (_ref) {
|
1825
1992
|
var _ref$styles = _ref.styles,
|
1826
1993
|
styles = _ref$styles === void 0 ? {} : _ref$styles,
|
1827
1994
|
props = _objectWithoutProperties(_ref, ["styles"]);
|
1828
1995
|
|
1829
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
1996
|
+
return /*#__PURE__*/React.createElement("svg", _extends$d({
|
1830
1997
|
"aria-hidden": "true",
|
1831
1998
|
"data-prefix": "fas",
|
1832
1999
|
"data-icon": "quote-right",
|
@@ -1860,6 +2027,8 @@ function Selection(props) {
|
|
1860
2027
|
range = _useContentElementEdi.range;
|
1861
2028
|
|
1862
2029
|
useEffect(function () {
|
2030
|
+
var _getUniformSelectedNo;
|
2031
|
+
|
1863
2032
|
var selection = editor.selection;
|
1864
2033
|
|
1865
2034
|
if (!ref.current) {
|
@@ -1914,8 +2083,8 @@ function Selection(props) {
|
|
1914
2083
|
|
1915
2084
|
setTransientState({
|
1916
2085
|
editableTextIsSingleBlock: editor.children.length <= 1,
|
1917
|
-
|
1918
|
-
typographyVariant:
|
2086
|
+
exampleNode: getUniformSelectedNode(editor, 'type'),
|
2087
|
+
typographyVariant: (_getUniformSelectedNo = getUniformSelectedNode(editor, 'variant')) === null || _getUniformSelectedNo === void 0 ? void 0 : _getUniformSelectedNo.variant
|
1919
2088
|
});
|
1920
2089
|
boundsRef.current = {
|
1921
2090
|
start: start,
|
@@ -2023,42 +2192,6 @@ function getDOMNodes(editor, startIndex, endIndex) {
|
|
2023
2192
|
}
|
2024
2193
|
}
|
2025
2194
|
|
2026
|
-
var listTypes = ['numbered-list', 'bulleted-list'];
|
2027
|
-
|
2028
|
-
function toggleBlock(editor, format) {
|
2029
|
-
var isActive = isBlockActive(editor, format);
|
2030
|
-
var isList = listTypes.includes(format);
|
2031
|
-
Transforms.unwrapNodes(editor, {
|
2032
|
-
match: function match(n) {
|
2033
|
-
return listTypes.includes(n.type);
|
2034
|
-
},
|
2035
|
-
split: true
|
2036
|
-
});
|
2037
|
-
Transforms.setNodes(editor, {
|
2038
|
-
type: isActive ? 'paragraph' : isList ? 'list-item' : format
|
2039
|
-
});
|
2040
|
-
|
2041
|
-
if (!isActive && isList) {
|
2042
|
-
var block = {
|
2043
|
-
type: format,
|
2044
|
-
children: []
|
2045
|
-
};
|
2046
|
-
Transforms.wrapNodes(editor, block);
|
2047
|
-
}
|
2048
|
-
}
|
2049
|
-
|
2050
|
-
function isBlockActive(editor, format) {
|
2051
|
-
var _Editor$nodes = Editor.nodes(editor, {
|
2052
|
-
match: function match(n) {
|
2053
|
-
return n.type === format;
|
2054
|
-
}
|
2055
|
-
}),
|
2056
|
-
_Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
|
2057
|
-
match = _Editor$nodes2[0];
|
2058
|
-
|
2059
|
-
return !!match;
|
2060
|
-
}
|
2061
|
-
|
2062
2195
|
function toolbarButtons(t) {
|
2063
2196
|
return [{
|
2064
2197
|
name: 'paragraph',
|
@@ -2217,19 +2350,126 @@ function measureHeights(editor, container) {
|
|
2217
2350
|
}]);
|
2218
2351
|
}
|
2219
2352
|
|
2353
|
+
var shy = "\xAD";
|
2354
|
+
function decorateCharacter(_ref, character, attributes, _ref2) {
|
2355
|
+
var _ref3 = _slicedToArray(_ref, 2),
|
2356
|
+
node = _ref3[0],
|
2357
|
+
path = _ref3[1];
|
2358
|
+
|
2359
|
+
var length = _ref2.length;
|
2360
|
+
|
2361
|
+
if (Text.isText(node)) {
|
2362
|
+
var parts = node.text.split(character);
|
2363
|
+
parts.pop();
|
2364
|
+
var i = 0;
|
2365
|
+
return parts.map(function (part) {
|
2366
|
+
i += part.length + 1;
|
2367
|
+
return _objectSpread2({
|
2368
|
+
anchor: {
|
2369
|
+
path: path,
|
2370
|
+
offset: i - 1
|
2371
|
+
},
|
2372
|
+
focus: {
|
2373
|
+
path: path,
|
2374
|
+
offset: i - 1 + length
|
2375
|
+
}
|
2376
|
+
}, attributes);
|
2377
|
+
});
|
2378
|
+
}
|
2379
|
+
|
2380
|
+
return [];
|
2381
|
+
}
|
2382
|
+
function deleteCharacter(editor, node, path, regExp) {
|
2383
|
+
var offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
2384
|
+
var match = regExp.exec(node.text);
|
2385
|
+
|
2386
|
+
if (match) {
|
2387
|
+
Transforms["delete"](editor, {
|
2388
|
+
at: {
|
2389
|
+
path: path,
|
2390
|
+
offset: match.index + offset
|
2391
|
+
},
|
2392
|
+
distance: 1,
|
2393
|
+
unit: 'character'
|
2394
|
+
});
|
2395
|
+
return true;
|
2396
|
+
}
|
2397
|
+
|
2398
|
+
return false;
|
2399
|
+
}
|
2400
|
+
|
2401
|
+
function useLineBreakHandler(editor) {
|
2402
|
+
return useCallback(function (event) {
|
2403
|
+
if (event.key !== 'Enter') {
|
2404
|
+
return;
|
2405
|
+
}
|
2406
|
+
|
2407
|
+
if (event.altKey === true) {
|
2408
|
+
editor.insertText(shy);
|
2409
|
+
event.preventDefault();
|
2410
|
+
} else if (event.shiftKey === true) {
|
2411
|
+
editor.insertText('\n');
|
2412
|
+
event.preventDefault();
|
2413
|
+
}
|
2414
|
+
}, [editor]);
|
2415
|
+
}
|
2416
|
+
function decorateLineBreaks(nodeEntry) {
|
2417
|
+
return decorateCharacter(nodeEntry, shy, {
|
2418
|
+
shy: true
|
2419
|
+
}, {
|
2420
|
+
length: 1
|
2421
|
+
});
|
2422
|
+
}
|
2423
|
+
function renderLeafWithLineBreakDecoration(_ref) {
|
2424
|
+
var leaf = _ref.leaf,
|
2425
|
+
children = _ref.children,
|
2426
|
+
attributes = _ref.attributes;
|
2427
|
+
|
2428
|
+
if (leaf.shy) {
|
2429
|
+
children = /*#__PURE__*/React.createElement("span", {
|
2430
|
+
className: styles$7.shy
|
2431
|
+
}, children);
|
2432
|
+
}
|
2433
|
+
|
2434
|
+
return renderLeaf$1({
|
2435
|
+
leaf: leaf,
|
2436
|
+
children: children,
|
2437
|
+
attributes: attributes
|
2438
|
+
});
|
2439
|
+
}
|
2440
|
+
function withLineBreakNormalization(editor) {
|
2441
|
+
var normalizeNode = editor.normalizeNode;
|
2442
|
+
|
2443
|
+
editor.normalizeNode = function (_ref2) {
|
2444
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
2445
|
+
node = _ref3[0],
|
2446
|
+
path = _ref3[1];
|
2447
|
+
|
2448
|
+
if (node.text) {
|
2449
|
+
if (deleteCharacter(editor, node, path, new RegExp("".concat(shy, "\\s"))) || deleteCharacter(editor, node, path, new RegExp("^".concat(shy))) || deleteCharacter(editor, node, path, new RegExp("\\s".concat(shy)), 1) || deleteCharacter(editor, node, path, new RegExp("".concat(shy).concat(shy)))) {
|
2450
|
+
return;
|
2451
|
+
}
|
2452
|
+
}
|
2453
|
+
|
2454
|
+
return normalizeNode([node, path]);
|
2455
|
+
};
|
2456
|
+
|
2457
|
+
return editor;
|
2458
|
+
}
|
2459
|
+
|
2220
2460
|
var EditableText = React.memo(function EditableText(_ref) {
|
2221
2461
|
var value = _ref.value,
|
2222
2462
|
contentElementId = _ref.contentElementId,
|
2223
2463
|
placeholder = _ref.placeholder,
|
2224
|
-
onChange = _ref.onChange
|
2464
|
+
onChange = _ref.onChange,
|
2465
|
+
selectionRect = _ref.selectionRect,
|
2466
|
+
className = _ref.className;
|
2225
2467
|
var editor = useMemo(function () {
|
2226
|
-
return withLinks(withCustomInsertBreak(
|
2227
|
-
|
2228
|
-
|
2229
|
-
|
2230
|
-
|
2231
|
-
linkSelection = _useState2[0],
|
2232
|
-
setLinkSelection = _useState2[1];
|
2468
|
+
return withLinks(withCustomInsertBreak(withBlockNormalization({
|
2469
|
+
onlyParagraphs: !selectionRect
|
2470
|
+
}, withLineBreakNormalization(withReact(createEditor())))));
|
2471
|
+
}, [selectionRect]);
|
2472
|
+
var handleLineBreaks = useLineBreakHandler(editor);
|
2233
2473
|
|
2234
2474
|
var _useCachedValue = useCachedValue(value, {
|
2235
2475
|
defaultValue: [{
|
@@ -2247,15 +2487,16 @@ var EditableText = React.memo(function EditableText(_ref) {
|
|
2247
2487
|
cachedValue = _useCachedValue2[0],
|
2248
2488
|
setCachedValue = _useCachedValue2[1];
|
2249
2489
|
|
2490
|
+
var _useContentElementEdi = useContentElementEditorState(),
|
2491
|
+
isSelected = _useContentElementEdi.isSelected;
|
2492
|
+
|
2250
2493
|
useContentElementEditorCommandSubscription(function (command) {
|
2251
2494
|
if (command.type === 'REMOVE') {
|
2252
2495
|
Transforms.removeNodes(editor, {
|
2253
2496
|
mode: 'highest'
|
2254
2497
|
});
|
2255
2498
|
} else if (command.type === 'TRANSIENT_STATE_UPDATE' && 'typographyVariant' in command.payload) {
|
2256
|
-
|
2257
|
-
variant: command.payload.typographyVariant
|
2258
|
-
});
|
2499
|
+
applyTypograpyhVariant(editor, command.payload.typographyVariant);
|
2259
2500
|
}
|
2260
2501
|
});
|
2261
2502
|
|
@@ -2264,37 +2505,27 @@ var EditableText = React.memo(function EditableText(_ref) {
|
|
2264
2505
|
dropTargetsActive = _useDropTargetsActive2[0],
|
2265
2506
|
ref = _useDropTargetsActive2[1];
|
2266
2507
|
|
2267
|
-
var decorate = useCallback(function (nodeEntry) {
|
2268
|
-
return decorateLinkSelection(nodeEntry, linkSelection);
|
2269
|
-
}, [linkSelection]); // Ensure Slate rerenders when decorations change
|
2270
|
-
// https://github.com/ianstormtaylor/slate/issues/3447
|
2271
|
-
|
2272
|
-
var renderLeaf = useCallback(function (options) {
|
2273
|
-
return renderLeafWithLinkSelection(options);
|
2274
|
-
}, [linkSelection]); // eslint-disable-line react-hooks/exhaustive-deps
|
2275
|
-
|
2276
2508
|
return /*#__PURE__*/React.createElement(Text$1, {
|
2277
2509
|
scaleCategory: "body"
|
2278
2510
|
}, /*#__PURE__*/React.createElement("div", {
|
2279
|
-
className: styles$7.container,
|
2511
|
+
className: classNames(styles$7.container, _defineProperty({}, styles$7.selected, isSelected)),
|
2280
2512
|
ref: ref
|
2281
2513
|
}, /*#__PURE__*/React.createElement(Slate, {
|
2282
2514
|
editor: editor,
|
2283
2515
|
value: cachedValue,
|
2284
2516
|
onChange: setCachedValue
|
2285
2517
|
}, /*#__PURE__*/React.createElement(LinkTooltipProvider, {
|
2286
|
-
|
2287
|
-
}, /*#__PURE__*/React.createElement(Selection, {
|
2518
|
+
editor: editor
|
2519
|
+
}, selectionRect && /*#__PURE__*/React.createElement(Selection, {
|
2288
2520
|
contentElementId: contentElementId
|
2289
2521
|
}), dropTargetsActive && /*#__PURE__*/React.createElement(DropTargets$1, {
|
2290
2522
|
contentElementId: contentElementId
|
2291
|
-
}), /*#__PURE__*/React.createElement(HoveringToolbar, {
|
2292
|
-
|
2293
|
-
|
2294
|
-
|
2295
|
-
decorate: decorate,
|
2523
|
+
}), /*#__PURE__*/React.createElement(HoveringToolbar, null), /*#__PURE__*/React.createElement(Editable, {
|
2524
|
+
className: className,
|
2525
|
+
decorate: decorateLineBreaks,
|
2526
|
+
onKeyDown: handleLineBreaks,
|
2296
2527
|
renderElement: renderElementWithLinkPreview,
|
2297
|
-
renderLeaf:
|
2528
|
+
renderLeaf: renderLeafWithLineBreakDecoration
|
2298
2529
|
}))), /*#__PURE__*/React.createElement(TextPlaceholder, {
|
2299
2530
|
text: placeholder,
|
2300
2531
|
visible: isBlank(cachedValue)
|
@@ -2326,14 +2557,17 @@ function hasTextAtPoint(editor, point) {
|
|
2326
2557
|
return Text.isText(node) && point.offset <= node.text.length;
|
2327
2558
|
}
|
2328
2559
|
|
2329
|
-
|
2330
|
-
function useLineBreakHandler(editor) {
|
2560
|
+
function useLineBreakHandler$1(editor) {
|
2331
2561
|
return useCallback(function (event) {
|
2332
2562
|
if (event.key !== 'Enter') {
|
2333
2563
|
return true;
|
2334
|
-
}
|
2564
|
+
} // Soft hyphens used to be inserted with Shift + Enter.
|
2565
|
+
// Since Shift + Enter is now used for soft breaks in text blocks,
|
2566
|
+
// we switched to Alt + Enter. Since all line breaks in
|
2567
|
+
// EdtiableInlineText are soft, we also keep the old short cut
|
2568
|
+
|
2335
2569
|
|
2336
|
-
if (event.shiftKey === true) {
|
2570
|
+
if (event.shiftKey === true || event.altKey === true) {
|
2337
2571
|
editor.insertText(shy);
|
2338
2572
|
} else {
|
2339
2573
|
editor.insertText('\n');
|
@@ -2342,7 +2576,7 @@ function useLineBreakHandler(editor) {
|
|
2342
2576
|
return false;
|
2343
2577
|
}, [editor]);
|
2344
2578
|
}
|
2345
|
-
function decorateLineBreaks(nodeEntry) {
|
2579
|
+
function decorateLineBreaks$1(nodeEntry) {
|
2346
2580
|
return [].concat(_toConsumableArray(decorateCharacter(nodeEntry, shy, {
|
2347
2581
|
shy: true
|
2348
2582
|
}, {
|
@@ -2353,43 +2587,13 @@ function decorateLineBreaks(nodeEntry) {
|
|
2353
2587
|
length: 0
|
2354
2588
|
})));
|
2355
2589
|
}
|
2356
|
-
|
2357
|
-
function decorateCharacter(_ref, character, attributes, _ref2) {
|
2358
|
-
var _ref3 = _slicedToArray(_ref, 2),
|
2359
|
-
node = _ref3[0],
|
2360
|
-
path = _ref3[1];
|
2361
|
-
|
2362
|
-
var length = _ref2.length;
|
2363
|
-
|
2364
|
-
if (Text.isText(node)) {
|
2365
|
-
var parts = node.text.split(character);
|
2366
|
-
parts.pop();
|
2367
|
-
var i = 0;
|
2368
|
-
return parts.map(function (part) {
|
2369
|
-
i += part.length + 1;
|
2370
|
-
return _objectSpread2({
|
2371
|
-
anchor: {
|
2372
|
-
path: path,
|
2373
|
-
offset: i - 1
|
2374
|
-
},
|
2375
|
-
focus: {
|
2376
|
-
path: path,
|
2377
|
-
offset: i - 1 + length
|
2378
|
-
}
|
2379
|
-
}, attributes);
|
2380
|
-
});
|
2381
|
-
}
|
2382
|
-
|
2383
|
-
return [];
|
2384
|
-
}
|
2385
|
-
|
2386
|
-
function withLineBreakNormalization(editor) {
|
2590
|
+
function withLineBreakNormalization$1(editor) {
|
2387
2591
|
var normalizeNode = editor.normalizeNode;
|
2388
2592
|
|
2389
|
-
editor.normalizeNode = function (
|
2390
|
-
var
|
2391
|
-
node =
|
2392
|
-
path =
|
2593
|
+
editor.normalizeNode = function (_ref) {
|
2594
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
2595
|
+
node = _ref2[0],
|
2596
|
+
path = _ref2[1];
|
2393
2597
|
|
2394
2598
|
if (path.length === 0 && editor.children.length > 1) {
|
2395
2599
|
Transforms.mergeNodes(editor);
|
@@ -2406,25 +2610,6 @@ function withLineBreakNormalization(editor) {
|
|
2406
2610
|
return editor;
|
2407
2611
|
}
|
2408
2612
|
|
2409
|
-
function deleteCharacter(editor, node, path, regExp) {
|
2410
|
-
var offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
2411
|
-
var match = regExp.exec(node.text);
|
2412
|
-
|
2413
|
-
if (match) {
|
2414
|
-
Transforms["delete"](editor, {
|
2415
|
-
at: {
|
2416
|
-
path: path,
|
2417
|
-
offset: match.index + offset
|
2418
|
-
},
|
2419
|
-
distance: 1,
|
2420
|
-
unit: 'character'
|
2421
|
-
});
|
2422
|
-
return true;
|
2423
|
-
}
|
2424
|
-
|
2425
|
-
return false;
|
2426
|
-
}
|
2427
|
-
|
2428
2613
|
var styles$9 = {"shy":"index-module_shy__1E2-J","newLine":"index-module_newLine__1QnIs","selected":"index-module_selected__1U9ro","manualHyphens":"index-module_manualHyphens__16b2t"};
|
2429
2614
|
|
2430
2615
|
var EditableInlineText = memo(function EditableInlineText(_ref) {
|
@@ -2437,9 +2622,9 @@ var EditableInlineText = memo(function EditableInlineText(_ref) {
|
|
2437
2622
|
placeholder = _ref.placeholder,
|
2438
2623
|
onChange = _ref.onChange;
|
2439
2624
|
var editor = useMemo(function () {
|
2440
|
-
return withLineBreakNormalization(withReact(createEditor()));
|
2625
|
+
return withLineBreakNormalization$1(withReact(createEditor()));
|
2441
2626
|
}, []);
|
2442
|
-
var handleLineBreaks = useLineBreakHandler(editor);
|
2627
|
+
var handleLineBreaks = useLineBreakHandler$1(editor);
|
2443
2628
|
|
2444
2629
|
var _useCachedValue = useCachedValue(value, {
|
2445
2630
|
defaultValue: [{
|
@@ -2458,14 +2643,14 @@ var EditableInlineText = memo(function EditableInlineText(_ref) {
|
|
2458
2643
|
isSelected = _useContentElementEdi.isSelected;
|
2459
2644
|
|
2460
2645
|
return /*#__PURE__*/React.createElement("div", {
|
2461
|
-
className: classNames(frontendStyles.root,
|
2646
|
+
className: classNames(frontendStyles.root, frontendStyles["hyphens-".concat(hyphens)], _defineProperty({}, styles$9.manualHyphens, hyphens === 'manual'), _defineProperty({}, styles$9.selected, isSelected)),
|
2462
2647
|
spellCheck: "false"
|
2463
2648
|
}, /*#__PURE__*/React.createElement(Slate, {
|
2464
2649
|
editor: editor,
|
2465
2650
|
value: cachedValue,
|
2466
2651
|
onChange: setCachedValue
|
2467
2652
|
}, /*#__PURE__*/React.createElement(Editable, {
|
2468
|
-
decorate: decorateLineBreaks,
|
2653
|
+
decorate: decorateLineBreaks$1,
|
2469
2654
|
onKeyDown: handleLineBreaks,
|
2470
2655
|
renderLeaf: renderLeaf
|
2471
2656
|
})), /*#__PURE__*/React.createElement(TextPlaceholder, {
|