@dextinity/admin-rte 2.0.0-canary-20260729062014
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/LICENSE +24 -0
- package/lib/core/BlockElement.d.ts +29 -0
- package/lib/core/BlockElement.d.ts.map +1 -0
- package/lib/core/BlockElement.js +43 -0
- package/lib/core/Controls/BlockTypesControls.d.ts +16 -0
- package/lib/core/Controls/BlockTypesControls.d.ts.map +1 -0
- package/lib/core/Controls/BlockTypesControls.js +91 -0
- package/lib/core/Controls/ControlButton.d.ts +28 -0
- package/lib/core/Controls/ControlButton.d.ts.map +1 -0
- package/lib/core/Controls/ControlButton.js +62 -0
- package/lib/core/Controls/Controls.d.ts +3 -0
- package/lib/core/Controls/Controls.d.ts.map +1 -0
- package/lib/core/Controls/Controls.js +30 -0
- package/lib/core/Controls/CustomControls.d.ts +3 -0
- package/lib/core/Controls/CustomControls.d.ts.map +1 -0
- package/lib/core/Controls/CustomControls.js +20 -0
- package/lib/core/Controls/FeaturesButtonGroup.d.ts +30 -0
- package/lib/core/Controls/FeaturesButtonGroup.d.ts.map +1 -0
- package/lib/core/Controls/FeaturesButtonGroup.js +147 -0
- package/lib/core/Controls/HistoryContols.d.ts +3 -0
- package/lib/core/Controls/HistoryContols.d.ts.map +1 -0
- package/lib/core/Controls/HistoryContols.js +24 -0
- package/lib/core/Controls/InlineStyleTypeControls.d.ts +3 -0
- package/lib/core/Controls/InlineStyleTypeControls.d.ts.map +1 -0
- package/lib/core/Controls/InlineStyleTypeControls.js +29 -0
- package/lib/core/Controls/LinkControls.d.ts +26 -0
- package/lib/core/Controls/LinkControls.d.ts.map +1 -0
- package/lib/core/Controls/LinkControls.js +54 -0
- package/lib/core/Controls/ListsControls.d.ts +3 -0
- package/lib/core/Controls/ListsControls.d.ts.map +1 -0
- package/lib/core/Controls/ListsControls.js +30 -0
- package/lib/core/Controls/ListsIndentControls.d.ts +3 -0
- package/lib/core/Controls/ListsIndentControls.d.ts.map +1 -0
- package/lib/core/Controls/ListsIndentControls.js +27 -0
- package/lib/core/Controls/SpecialCharactersControls.d.ts +4 -0
- package/lib/core/Controls/SpecialCharactersControls.d.ts.map +1 -0
- package/lib/core/Controls/SpecialCharactersControls.js +20 -0
- package/lib/core/Controls/Toolbar/Toolbar.d.ts +28 -0
- package/lib/core/Controls/Toolbar/Toolbar.d.ts.map +1 -0
- package/lib/core/Controls/Toolbar/Toolbar.js +41 -0
- package/lib/core/Controls/Toolbar/Toolbar.styles.d.ts +14 -0
- package/lib/core/Controls/Toolbar/Toolbar.styles.d.ts.map +1 -0
- package/lib/core/Controls/Toolbar/Toolbar.styles.js +21 -0
- package/lib/core/Controls/TranslationControls.d.ts +4 -0
- package/lib/core/Controls/TranslationControls.d.ts.map +1 -0
- package/lib/core/Controls/TranslationControls.js +20 -0
- package/lib/core/Controls/useBlockTypes.d.ts +23 -0
- package/lib/core/Controls/useBlockTypes.d.ts.map +1 -0
- package/lib/core/Controls/useBlockTypes.js +116 -0
- package/lib/core/Controls/useHistory.d.ts +13 -0
- package/lib/core/Controls/useHistory.d.ts.map +1 -0
- package/lib/core/Controls/useHistory.js +63 -0
- package/lib/core/Controls/useInlineStyleType.d.ts +16 -0
- package/lib/core/Controls/useInlineStyleType.d.ts.map +1 -0
- package/lib/core/Controls/useInlineStyleType.js +148 -0
- package/lib/core/Controls/useListIndent.d.ts +14 -0
- package/lib/core/Controls/useListIndent.d.ts.map +1 -0
- package/lib/core/Controls/useListIndent.js +114 -0
- package/lib/core/Rte.d.ts +72 -0
- package/lib/core/Rte.d.ts.map +1 -0
- package/lib/core/Rte.js +256 -0
- package/lib/core/RteReadOnly.d.ts +19 -0
- package/lib/core/RteReadOnly.d.ts.map +1 -0
- package/lib/core/RteReadOnly.js +62 -0
- package/lib/core/defaultBlocktypeMap.d.ts +6 -0
- package/lib/core/defaultBlocktypeMap.d.ts.map +1 -0
- package/lib/core/defaultBlocktypeMap.js +235 -0
- package/lib/core/extension/Link/Decorator.d.ts +5 -0
- package/lib/core/extension/Link/Decorator.d.ts.map +1 -0
- package/lib/core/extension/Link/Decorator.js +13 -0
- package/lib/core/extension/Link/EditorComponent.d.ts +12 -0
- package/lib/core/extension/Link/EditorComponent.d.ts.map +1 -0
- package/lib/core/extension/Link/EditorComponent.js +14 -0
- package/lib/core/extension/Link/ToolbarButton.d.ts +3 -0
- package/lib/core/extension/Link/ToolbarButton.d.ts.map +1 -0
- package/lib/core/extension/Link/ToolbarButton.js +162 -0
- package/lib/core/extension/LinksRemove/ToolbarButton.d.ts +3 -0
- package/lib/core/extension/LinksRemove/ToolbarButton.d.ts.map +1 -0
- package/lib/core/extension/LinksRemove/ToolbarButton.js +20 -0
- package/lib/core/extension/NonBreakingSpace/Decorator.d.ts +4 -0
- package/lib/core/extension/NonBreakingSpace/Decorator.d.ts.map +1 -0
- package/lib/core/extension/NonBreakingSpace/Decorator.js +17 -0
- package/lib/core/extension/NonBreakingSpace/EditorComponent.d.ts +9 -0
- package/lib/core/extension/NonBreakingSpace/EditorComponent.d.ts.map +1 -0
- package/lib/core/extension/NonBreakingSpace/EditorComponent.js +37 -0
- package/lib/core/extension/NonBreakingSpace/ToolbarButton.d.ts +4 -0
- package/lib/core/extension/NonBreakingSpace/ToolbarButton.d.ts.map +1 -0
- package/lib/core/extension/NonBreakingSpace/ToolbarButton.js +42 -0
- package/lib/core/extension/SoftHyphen/Decorator.d.ts +4 -0
- package/lib/core/extension/SoftHyphen/Decorator.d.ts.map +1 -0
- package/lib/core/extension/SoftHyphen/Decorator.js +17 -0
- package/lib/core/extension/SoftHyphen/EditorComponent.d.ts +9 -0
- package/lib/core/extension/SoftHyphen/EditorComponent.d.ts.map +1 -0
- package/lib/core/extension/SoftHyphen/EditorComponent.js +24 -0
- package/lib/core/extension/SoftHyphen/ToolbarButton.d.ts +3 -0
- package/lib/core/extension/SoftHyphen/ToolbarButton.d.ts.map +1 -0
- package/lib/core/extension/SoftHyphen/ToolbarButton.js +35 -0
- package/lib/core/filterEditor/composeFilterEditorFns.d.ts +4 -0
- package/lib/core/filterEditor/composeFilterEditorFns.d.ts.map +1 -0
- package/lib/core/filterEditor/composeFilterEditorFns.js +8 -0
- package/lib/core/filterEditor/default.d.ts +4 -0
- package/lib/core/filterEditor/default.d.ts.map +1 -0
- package/lib/core/filterEditor/default.js +16 -0
- package/lib/core/filterEditor/manageStandardBlockType.d.ts +4 -0
- package/lib/core/filterEditor/manageStandardBlockType.d.ts.map +1 -0
- package/lib/core/filterEditor/manageStandardBlockType.js +16 -0
- package/lib/core/filterEditor/removeBlocksExceedingBlockLimit.d.ts +4 -0
- package/lib/core/filterEditor/removeBlocksExceedingBlockLimit.d.ts.map +1 -0
- package/lib/core/filterEditor/removeBlocksExceedingBlockLimit.js +22 -0
- package/lib/core/filterEditor/removeUnsupportedBlockTypes.d.ts +4 -0
- package/lib/core/filterEditor/removeUnsupportedBlockTypes.d.ts.map +1 -0
- package/lib/core/filterEditor/removeUnsupportedBlockTypes.js +35 -0
- package/lib/core/filterEditor/removeUnsupportedEntities.d.ts +4 -0
- package/lib/core/filterEditor/removeUnsupportedEntities.d.ts.map +1 -0
- package/lib/core/filterEditor/removeUnsupportedEntities.js +18 -0
- package/lib/core/filterEditor/removeUnsupportedInlineStyles.d.ts +4 -0
- package/lib/core/filterEditor/removeUnsupportedInlineStyles.d.ts.map +1 -0
- package/lib/core/filterEditor/removeUnsupportedInlineStyles.js +26 -0
- package/lib/core/filterEditor/removeUnsupportedListLevels.d.ts +4 -0
- package/lib/core/filterEditor/removeUnsupportedListLevels.d.ts.map +1 -0
- package/lib/core/filterEditor/removeUnsupportedListLevels.js +16 -0
- package/lib/core/filterEditor/utils/changeBlockType.d.ts +9 -0
- package/lib/core/filterEditor/utils/changeBlockType.d.ts.map +1 -0
- package/lib/core/filterEditor/utils/changeBlockType.js +37 -0
- package/lib/core/filterEditor/utils/manipulateEntityData.d.ts +6 -0
- package/lib/core/filterEditor/utils/manipulateEntityData.d.ts.map +1 -0
- package/lib/core/filterEditor/utils/manipulateEntityData.js +43 -0
- package/lib/core/filterEditor/utils/removeEntities.d.ts +6 -0
- package/lib/core/filterEditor/utils/removeEntities.d.ts.map +1 -0
- package/lib/core/filterEditor/utils/removeEntities.js +34 -0
- package/lib/core/filterEditor/utils/removeInlineStyles.d.ts +5 -0
- package/lib/core/filterEditor/utils/removeInlineStyles.d.ts.map +1 -0
- package/lib/core/filterEditor/utils/removeInlineStyles.js +28 -0
- package/lib/core/makeRteApi.d.ts +26 -0
- package/lib/core/makeRteApi.d.ts.map +1 -0
- package/lib/core/makeRteApi.js +86 -0
- package/lib/core/translation/EditorStateTranslationDialog.d.ts +11 -0
- package/lib/core/translation/EditorStateTranslationDialog.d.ts.map +1 -0
- package/lib/core/translation/EditorStateTranslationDialog.js +32 -0
- package/lib/core/translation/ToolbarButton.d.ts +4 -0
- package/lib/core/translation/ToolbarButton.d.ts.map +1 -0
- package/lib/core/translation/ToolbarButton.js +98 -0
- package/lib/core/translation/htmlToState.d.ts +9 -0
- package/lib/core/translation/htmlToState.d.ts.map +1 -0
- package/lib/core/translation/htmlToState.js +53 -0
- package/lib/core/translation/htmlToState.spec.d.ts +2 -0
- package/lib/core/translation/htmlToState.spec.d.ts.map +1 -0
- package/lib/core/translation/stateToHtml.d.ts +13 -0
- package/lib/core/translation/stateToHtml.d.ts.map +1 -0
- package/lib/core/translation/stateToHtml.js +60 -0
- package/lib/core/translation/stateToHtml.spec.d.ts +2 -0
- package/lib/core/translation/stateToHtml.spec.d.ts.map +1 -0
- package/lib/core/types.d.ts +64 -0
- package/lib/core/types.d.ts.map +1 -0
- package/lib/core/types.js +1 -0
- package/lib/core/utils/createBlockRenderMap.d.ts +6 -0
- package/lib/core/utils/createBlockRenderMap.d.ts.map +1 -0
- package/lib/core/utils/createBlockRenderMap.js +22 -0
- package/lib/core/utils/findEntityDataInCurrentSelection.d.ts +3 -0
- package/lib/core/utils/findEntityDataInCurrentSelection.d.ts.map +1 -0
- package/lib/core/utils/findEntityDataInCurrentSelection.js +12 -0
- package/lib/core/utils/findEntityInCurrentSelection.d.ts +8 -0
- package/lib/core/utils/findEntityInCurrentSelection.d.ts.map +1 -0
- package/lib/core/utils/findEntityInCurrentSelection.js +81 -0
- package/lib/core/utils/findTextInCurrentSelection.d.ts +3 -0
- package/lib/core/utils/findTextInCurrentSelection.d.ts.map +1 -0
- package/lib/core/utils/findTextInCurrentSelection.js +16 -0
- package/lib/core/utils/getCurrentBlock.d.ts +3 -0
- package/lib/core/utils/getCurrentBlock.d.ts.map +1 -0
- package/lib/core/utils/getCurrentBlock.js +7 -0
- package/lib/core/utils/getRteTheme.d.ts +19 -0
- package/lib/core/utils/getRteTheme.d.ts.map +1 -0
- package/lib/core/utils/getRteTheme.js +18 -0
- package/lib/core/utils/pasteAndFilterText.d.ts +5 -0
- package/lib/core/utils/pasteAndFilterText.d.ts.map +1 -0
- package/lib/core/utils/pasteAndFilterText.js +17 -0
- package/lib/core/utils/rangesIntersect.d.ts +6 -0
- package/lib/core/utils/rangesIntersect.d.ts.map +1 -0
- package/lib/core/utils/rangesIntersect.js +22 -0
- package/lib/core/utils/selectionIsInOneBlock.d.ts +3 -0
- package/lib/core/utils/selectionIsInOneBlock.d.ts.map +1 -0
- package/lib/core/utils/selectionIsInOneBlock.js +6 -0
- package/lib/field/createFinalFormRte.d.ts +22 -0
- package/lib/field/createFinalFormRte.d.ts.map +1 -0
- package/lib/field/createFinalFormRte.js +84 -0
- package/lib/field/createRteField.d.ts +13 -0
- package/lib/field/createRteField.d.ts.map +1 -0
- package/lib/field/createRteField.js +44 -0
- package/lib/index.d.ts +31 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +29 -0
- package/lib/useDebounce.d.ts +2 -0
- package/lib/useDebounce.d.ts.map +1 -0
- package/lib/useDebounce.js +32 -0
- package/lib/usePrevious.d.ts +4 -0
- package/lib/usePrevious.d.ts.map +1 -0
- package/lib/usePrevious.js +20 -0
- package/lib/utils/requiredValidator.d.ts +4 -0
- package/lib/utils/requiredValidator.d.ts.map +1 -0
- package/lib/utils/requiredValidator.js +16 -0
- package/package.json +93 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "draft-js/dist/Draft.css";
|
|
2
|
+
import { type EditorState } from "draft-js";
|
|
3
|
+
import type { IBlocktypeMap as IBlocktypeMap, ICustomBlockTypeMap_Deprecated } from "./types";
|
|
4
|
+
interface IRteReadOnlyOptions {
|
|
5
|
+
blocktypeMap: IBlocktypeMap;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use `blocktypeMap` instead
|
|
8
|
+
*/
|
|
9
|
+
customBlockMap?: ICustomBlockTypeMap_Deprecated;
|
|
10
|
+
}
|
|
11
|
+
export type IOptions = Partial<IRteReadOnlyOptions>;
|
|
12
|
+
export interface IProps {
|
|
13
|
+
value: EditorState;
|
|
14
|
+
plainTextOnly?: boolean;
|
|
15
|
+
options?: IOptions;
|
|
16
|
+
}
|
|
17
|
+
declare const RteReadOnly: ({ value: editorState, options: passedOptions, plainTextOnly }: IProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export default RteReadOnly;
|
|
19
|
+
//# sourceMappingURL=RteReadOnly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RteReadOnly.d.ts","sourceRoot":"","sources":["../../src/core/RteReadOnly.tsx"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAKrE,OAAO,KAAK,EAAE,aAAa,IAAI,aAAa,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AAG9F,UAAU,mBAAmB;IACzB,YAAY,EAAE,aAAa,CAAC;IAC5B;;OAEG;IACH,cAAc,CAAC,EAAE,8BAA8B,CAAC;CACnD;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAEpD,MAAM,WAAW,MAAM;IACnB,KAAK,EAAE,WAAW,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,QAAQ,CAAC;CACtB;AAMD,QAAA,MAAM,WAAW,GAAI,+DAA+D,MAAM,4CA4CzF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import "draft-js/dist/Draft.css"; // important for nesting of ul/ol
|
|
8
|
+
|
|
9
|
+
import { Editor as DraftJsEditor } from "draft-js";
|
|
10
|
+
import { useRef } from "react";
|
|
11
|
+
import defaultBlocktypeMap, { cleanBlockTypeMap, mergeBlocktypeMaps } from "./defaultBlocktypeMap";
|
|
12
|
+
import { styleMap } from "./Rte";
|
|
13
|
+
import createBlockRenderMap from "./utils/createBlockRenderMap";
|
|
14
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
var defaultOptions = {
|
|
16
|
+
blocktypeMap: defaultBlocktypeMap
|
|
17
|
+
};
|
|
18
|
+
var RteReadOnly = function RteReadOnly(_ref) {
|
|
19
|
+
var editorState = _ref.value,
|
|
20
|
+
passedOptions = _ref.options,
|
|
21
|
+
plainTextOnly = _ref.plainTextOnly;
|
|
22
|
+
var editorRef = useRef(null);
|
|
23
|
+
|
|
24
|
+
// merge default options with passed options
|
|
25
|
+
var options = passedOptions ? _objectSpread(_objectSpread({}, defaultOptions), passedOptions) : defaultOptions;
|
|
26
|
+
|
|
27
|
+
// extract deprecated options and handle them specially
|
|
28
|
+
var deprecatedCustomBlockMap = {};
|
|
29
|
+
if (options.customBlockMap) {
|
|
30
|
+
deprecatedCustomBlockMap = options.customBlockMap;
|
|
31
|
+
delete options.customBlockMap;
|
|
32
|
+
}
|
|
33
|
+
cleanBlockTypeMap(options.blocktypeMap); // mutate object and print warning when configuration is wrong
|
|
34
|
+
|
|
35
|
+
// blocktypes need an extra merge as they have their own merge strategy
|
|
36
|
+
options = _objectSpread(_objectSpread({}, options), {}, {
|
|
37
|
+
blocktypeMap: mergeBlocktypeMaps(defaultBlocktypeMap, deprecatedCustomBlockMap, options.blocktypeMap)
|
|
38
|
+
});
|
|
39
|
+
var blockRenderMap = createBlockRenderMap({
|
|
40
|
+
blocktypeMap: options.blocktypeMap
|
|
41
|
+
});
|
|
42
|
+
function handleOnChange() {
|
|
43
|
+
if (editorRef.current) {
|
|
44
|
+
editorRef.current.blur();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (plainTextOnly) {
|
|
48
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
49
|
+
children: editorState.getCurrentContent().getPlainText()
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return /*#__PURE__*/_jsx(DraftJsEditor, {
|
|
53
|
+
ref: editorRef,
|
|
54
|
+
editorState: editorState,
|
|
55
|
+
onChange: handleOnChange,
|
|
56
|
+
spellCheck: false,
|
|
57
|
+
customStyleMap: styleMap,
|
|
58
|
+
readOnly: true,
|
|
59
|
+
blockRenderMap: blockRenderMap
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
export default RteReadOnly;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IBlocktypeMap } from "./types";
|
|
2
|
+
declare const defaultBlocktypeMap: IBlocktypeMap;
|
|
3
|
+
export declare function mergeBlocktypeMaps(...args: IBlocktypeMap[]): IBlocktypeMap;
|
|
4
|
+
export declare function cleanBlockTypeMap(map: IBlocktypeMap): IBlocktypeMap;
|
|
5
|
+
export default defaultBlocktypeMap;
|
|
6
|
+
//# sourceMappingURL=defaultBlocktypeMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultBlocktypeMap.d.ts","sourceRoot":"","sources":["../../src/core/defaultBlocktypeMap.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAI/D,QAAA,MAAM,mBAAmB,EAAE,aA+F1B,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,GAAG,IAAI,EAAE,aAAa,EAAE,iBAmB1D;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,iBAgBnD;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
5
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
6
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
7
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
+
import { RteOl, RteUl } from "@dextinity/admin-icons";
|
|
14
|
+
import { defineMessage, FormattedMessage } from "react-intl";
|
|
15
|
+
import { BlockElement } from "./BlockElement";
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
var headerMessage = defineMessage({
|
|
18
|
+
id: "comet.rte.controls.blockType.heading",
|
|
19
|
+
defaultMessage: "Heading {level}"
|
|
20
|
+
});
|
|
21
|
+
var defaultBlocktypeMap = {
|
|
22
|
+
// "unstyled" is special: only the value for renderConfig and label is considered,
|
|
23
|
+
// other values are ignored
|
|
24
|
+
unstyled: {
|
|
25
|
+
//info: https://draftjs.org/docs/advanced-topics-custom-block-render-map/#configuring-block-render-map
|
|
26
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
27
|
+
id: "comet.rte.controls.blockType.default",
|
|
28
|
+
defaultMessage: "Default"
|
|
29
|
+
}),
|
|
30
|
+
renderConfig: {
|
|
31
|
+
element: BlockElement,
|
|
32
|
+
aliasedElements: ["p"]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"header-one": {
|
|
36
|
+
supportedBy: "header-one",
|
|
37
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, _objectSpread(_objectSpread({}, headerMessage), {}, {
|
|
38
|
+
values: {
|
|
39
|
+
level: 1
|
|
40
|
+
}
|
|
41
|
+
})),
|
|
42
|
+
group: "dropdown",
|
|
43
|
+
renderConfig: {
|
|
44
|
+
element: function element(p) {
|
|
45
|
+
return /*#__PURE__*/_jsx(BlockElement, _objectSpread({
|
|
46
|
+
type: "header-one",
|
|
47
|
+
variant: "h1"
|
|
48
|
+
}, p));
|
|
49
|
+
},
|
|
50
|
+
aliasedElements: ["h1"] // important for matching tags when "word-content" is pasted into rte
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"header-two": {
|
|
54
|
+
supportedBy: "header-two",
|
|
55
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, _objectSpread(_objectSpread({}, headerMessage), {}, {
|
|
56
|
+
values: {
|
|
57
|
+
level: 2
|
|
58
|
+
}
|
|
59
|
+
})),
|
|
60
|
+
group: "dropdown",
|
|
61
|
+
renderConfig: {
|
|
62
|
+
element: function element(p) {
|
|
63
|
+
return /*#__PURE__*/_jsx(BlockElement, _objectSpread({
|
|
64
|
+
type: "header-two",
|
|
65
|
+
variant: "h2"
|
|
66
|
+
}, p));
|
|
67
|
+
},
|
|
68
|
+
aliasedElements: ["h2"]
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"header-three": {
|
|
72
|
+
supportedBy: "header-three",
|
|
73
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, _objectSpread(_objectSpread({}, headerMessage), {}, {
|
|
74
|
+
values: {
|
|
75
|
+
level: 3
|
|
76
|
+
}
|
|
77
|
+
})),
|
|
78
|
+
group: "dropdown",
|
|
79
|
+
renderConfig: {
|
|
80
|
+
element: function element(p) {
|
|
81
|
+
return /*#__PURE__*/_jsx(BlockElement, _objectSpread({
|
|
82
|
+
type: "header-three",
|
|
83
|
+
variant: "h3"
|
|
84
|
+
}, p));
|
|
85
|
+
},
|
|
86
|
+
aliasedElements: ["h3"]
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"header-four": {
|
|
90
|
+
supportedBy: "header-four",
|
|
91
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, _objectSpread(_objectSpread({}, headerMessage), {}, {
|
|
92
|
+
values: {
|
|
93
|
+
level: 4
|
|
94
|
+
}
|
|
95
|
+
})),
|
|
96
|
+
group: "dropdown",
|
|
97
|
+
renderConfig: {
|
|
98
|
+
element: function element(p) {
|
|
99
|
+
return /*#__PURE__*/_jsx(BlockElement, _objectSpread({
|
|
100
|
+
type: "header-four",
|
|
101
|
+
variant: "h4"
|
|
102
|
+
}, p));
|
|
103
|
+
},
|
|
104
|
+
aliasedElements: ["h4"]
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"header-five": {
|
|
108
|
+
supportedBy: "header-five",
|
|
109
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, _objectSpread(_objectSpread({}, headerMessage), {}, {
|
|
110
|
+
values: {
|
|
111
|
+
level: 5
|
|
112
|
+
}
|
|
113
|
+
})),
|
|
114
|
+
group: "dropdown",
|
|
115
|
+
renderConfig: {
|
|
116
|
+
element: function element(p) {
|
|
117
|
+
return /*#__PURE__*/_jsx(BlockElement, _objectSpread({
|
|
118
|
+
type: "header-five",
|
|
119
|
+
variant: "h5"
|
|
120
|
+
}, p));
|
|
121
|
+
},
|
|
122
|
+
aliasedElements: ["h5"]
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"header-six": {
|
|
126
|
+
supportedBy: "header-six",
|
|
127
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, _objectSpread(_objectSpread({}, headerMessage), {}, {
|
|
128
|
+
values: {
|
|
129
|
+
level: 6
|
|
130
|
+
}
|
|
131
|
+
})),
|
|
132
|
+
group: "dropdown",
|
|
133
|
+
renderConfig: {
|
|
134
|
+
element: function element(p) {
|
|
135
|
+
return /*#__PURE__*/_jsx(BlockElement, _objectSpread({
|
|
136
|
+
type: "header-six",
|
|
137
|
+
variant: "h6"
|
|
138
|
+
}, p));
|
|
139
|
+
},
|
|
140
|
+
aliasedElements: ["h6"]
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
blockquote: {
|
|
144
|
+
supportedBy: "blockquote",
|
|
145
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
146
|
+
id: "comet.rte.controls.blockType.blockquote",
|
|
147
|
+
defaultMessage: "Blockquote"
|
|
148
|
+
}),
|
|
149
|
+
renderConfig: {
|
|
150
|
+
element: function element(p) {
|
|
151
|
+
return /*#__PURE__*/_jsx(BlockElement, _objectSpread({
|
|
152
|
+
type: "blockquote"
|
|
153
|
+
}, p));
|
|
154
|
+
},
|
|
155
|
+
aliasedElements: ["blockquote"]
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"unordered-list-item": {
|
|
159
|
+
supportedBy: "unordered-list",
|
|
160
|
+
group: "button",
|
|
161
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
162
|
+
id: "comet.rte.controls.blockType.unorderedList",
|
|
163
|
+
defaultMessage: "Bulletpoints"
|
|
164
|
+
}),
|
|
165
|
+
icon: RteUl,
|
|
166
|
+
renderConfig: {
|
|
167
|
+
wrapper: /*#__PURE__*/_jsx(BlockElement, {
|
|
168
|
+
type: "unordered-list",
|
|
169
|
+
component: "ul"
|
|
170
|
+
}),
|
|
171
|
+
element: "li" // Do not change this to a react component (<Typography {...p}/>) unless you implement the css for nesting lists yourself!
|
|
172
|
+
// This css is used by default and it handles the nesting: https://github.com/facebook/draft-js/blob/master/src/component/utils/DraftStyleDefault.css#L152
|
|
173
|
+
// But for this css to be applied "element" needs to be an (undecorated) li-element
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"ordered-list-item": {
|
|
177
|
+
supportedBy: "ordered-list",
|
|
178
|
+
group: "button",
|
|
179
|
+
label: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
180
|
+
id: "comet.rte.controls.blockType.orderedList",
|
|
181
|
+
defaultMessage: "Numbering"
|
|
182
|
+
}),
|
|
183
|
+
icon: RteOl,
|
|
184
|
+
renderConfig: {
|
|
185
|
+
wrapper: /*#__PURE__*/_jsx(BlockElement, {
|
|
186
|
+
type: "ordered-list",
|
|
187
|
+
component: "ol"
|
|
188
|
+
}),
|
|
189
|
+
element: "li" // same thing that applies to unordered-list-item applies here too!
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
export function mergeBlocktypeMaps() {
|
|
194
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
195
|
+
args[_key] = arguments[_key];
|
|
196
|
+
}
|
|
197
|
+
return args.reduce(function (a, b) {
|
|
198
|
+
var remainingA = _objectSpread({}, a); // copy or bad things happen
|
|
199
|
+
var newEl = {};
|
|
200
|
+
Object.entries(b).forEach(function (_ref) {
|
|
201
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
202
|
+
key = _ref2[0],
|
|
203
|
+
c = _ref2[1];
|
|
204
|
+
if (remainingA[key]) {
|
|
205
|
+
// merge 2nd level
|
|
206
|
+
newEl[key] = _objectSpread(_objectSpread({}, remainingA[key]), c);
|
|
207
|
+
delete remainingA[key];
|
|
208
|
+
} else {
|
|
209
|
+
newEl[key] = _objectSpread({}, c); // only one level
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
// merge in remaining
|
|
213
|
+
Object.entries(remainingA).forEach(function (_ref3) {
|
|
214
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
215
|
+
key = _ref4[0],
|
|
216
|
+
c = _ref4[1];
|
|
217
|
+
newEl[key] = _objectSpread({}, c);
|
|
218
|
+
});
|
|
219
|
+
return newEl;
|
|
220
|
+
}); // merge 2 levels nested
|
|
221
|
+
}
|
|
222
|
+
export function cleanBlockTypeMap(map) {
|
|
223
|
+
// these unsupportedKeysForUnstyled canot be changed
|
|
224
|
+
var unsupportedKeysForUnstyled = ["group", "icon", "supportedBy"];
|
|
225
|
+
if (map !== null && map !== void 0 && map.unstyled) {
|
|
226
|
+
unsupportedKeysForUnstyled.forEach(function (c) {
|
|
227
|
+
if (map.unstyled[c]) {
|
|
228
|
+
map.unstyled[c] = undefined;
|
|
229
|
+
console.warn("'unstyled' in BlocktypeMap does not support the key '".concat(c, "' with the given value '").concat(map.unstyled[c], "'. The value is ignored."));
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return map;
|
|
234
|
+
}
|
|
235
|
+
export default defaultBlocktypeMap;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Decorator.d.ts","sourceRoot":"","sources":["../../../../src/core/extension/Link/Decorator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/C,eAAO,MAAM,WAAW,SAAS,CAAC;AAElC,QAAA,MAAM,SAAS,EAAE,cAShB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import EditorComponent from "./EditorComponent";
|
|
2
|
+
export var ENTITY_TYPE = "LINK";
|
|
3
|
+
var Decorator = {
|
|
4
|
+
strategy: function strategy(contentBlock, callback, contentState) {
|
|
5
|
+
// findEntities
|
|
6
|
+
contentBlock.findEntityRanges(function (character) {
|
|
7
|
+
var entityKey = character.getEntity();
|
|
8
|
+
return entityKey !== null && contentState.getEntity(entityKey).getType() === ENTITY_TYPE;
|
|
9
|
+
}, callback);
|
|
10
|
+
},
|
|
11
|
+
component: EditorComponent
|
|
12
|
+
};
|
|
13
|
+
export default Decorator;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ContentState } from "draft-js";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
interface IProps {
|
|
4
|
+
contentState: ContentState;
|
|
5
|
+
entityKey: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ILinkProps {
|
|
8
|
+
url: string;
|
|
9
|
+
}
|
|
10
|
+
declare const EditorComponent: (props: PropsWithChildren<IProps>) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default EditorComponent;
|
|
12
|
+
//# sourceMappingURL=EditorComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorComponent.d.ts","sourceRoot":"","sources":["../../../../src/core/extension/Link/EditorComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,UAAU,MAAM;IACZ,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACvB,GAAG,EAAE,MAAM,CAAC;CACf;AAED,QAAA,MAAM,eAAe,GAAI,OAAO,iBAAiB,CAAC,MAAM,CAAC,4CAaxD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
var EditorComponent = function EditorComponent(props) {
|
|
3
|
+
var _ref = props.contentState.getEntity(props.entityKey).getData(),
|
|
4
|
+
url = _ref.url; // not typed
|
|
5
|
+
return /*#__PURE__*/_jsx("a", {
|
|
6
|
+
href: url,
|
|
7
|
+
style: {
|
|
8
|
+
color: "#3b5998",
|
|
9
|
+
textDecoration: "underline"
|
|
10
|
+
},
|
|
11
|
+
children: props.children
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
export default EditorComponent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarButton.d.ts","sourceRoot":"","sources":["../../../../src/core/extension/Link/ToolbarButton.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAOjD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAK,EAAE,aAAa,2CAkCzD"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import { Button } from "@dextinity/admin";
|
|
8
|
+
import { Check, Close, Delete, RteLink } from "@dextinity/admin-icons";
|
|
9
|
+
import {
|
|
10
|
+
// eslint-disable-next-line no-restricted-imports
|
|
11
|
+
Dialog, DialogActions, DialogContent, DialogTitle, FormControl, FormLabel, Grid, InputBase } from "@mui/material";
|
|
12
|
+
import { EditorState, RichUtils } from "draft-js";
|
|
13
|
+
import { useEffect, useState } from "react";
|
|
14
|
+
import { FormattedMessage } from "react-intl";
|
|
15
|
+
import { ControlButton } from "../../Controls/ControlButton";
|
|
16
|
+
import findEntityDataInCurrentSelection from "../../utils/findEntityDataInCurrentSelection";
|
|
17
|
+
import findEntityInCurrentSelection from "../../utils/findEntityInCurrentSelection";
|
|
18
|
+
import selectionIsInOneBlock from "../../utils/selectionIsInOneBlock";
|
|
19
|
+
import { ENTITY_TYPE } from "./Decorator";
|
|
20
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
export default function ToolbarButton(props) {
|
|
22
|
+
var _useState = useState(false),
|
|
23
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
+
open = _useState2[0],
|
|
25
|
+
setOpen = _useState2[1];
|
|
26
|
+
var linkData = findEntityDataInCurrentSelection(props.editorState, ENTITY_TYPE);
|
|
27
|
+
var _findEntityInCurrentS = findEntityInCurrentSelection(props.editorState, ENTITY_TYPE),
|
|
28
|
+
previousLinkEntity = _findEntityInCurrentS.entity,
|
|
29
|
+
linkEntitySelection = _findEntityInCurrentS.entitySelection;
|
|
30
|
+
var selection = props.editorState.getSelection();
|
|
31
|
+
var linkEditCreateDisabled = selection.isCollapsed() && !linkData || !selectionIsInOneBlock(props.editorState);
|
|
32
|
+
var globallyDisabled = !!props.disabled;
|
|
33
|
+
function handleClick(e) {
|
|
34
|
+
if (linkEditCreateDisabled) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (previousLinkEntity && linkEntitySelection) {
|
|
38
|
+
// when there is a previous LINK entity found in the selection, force-shrink the selection to the text of this link entity
|
|
39
|
+
// like this we avoid nested links
|
|
40
|
+
props.setEditorState(EditorState.forceSelection(props.editorState, linkEntitySelection));
|
|
41
|
+
}
|
|
42
|
+
setOpen(true);
|
|
43
|
+
}
|
|
44
|
+
return /*#__PURE__*/_jsx(ControlButton, {
|
|
45
|
+
selected: !!linkData,
|
|
46
|
+
disabled: linkEditCreateDisabled || globallyDisabled,
|
|
47
|
+
icon: RteLink,
|
|
48
|
+
onButtonClick: handleClick,
|
|
49
|
+
children: /*#__PURE__*/_jsx(LinkDialog, {
|
|
50
|
+
editorState: props.editorState,
|
|
51
|
+
onChange: props.setEditorState,
|
|
52
|
+
linkData: linkData,
|
|
53
|
+
open: open,
|
|
54
|
+
onClose: function onClose() {
|
|
55
|
+
setOpen(false);
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function LinkDialog(props) {
|
|
61
|
+
var onClose = props.onClose,
|
|
62
|
+
open = props.open,
|
|
63
|
+
linkData = props.linkData,
|
|
64
|
+
editorState = props.editorState,
|
|
65
|
+
onChange = props.onChange;
|
|
66
|
+
var linkDataUrl = linkData ? linkData.url : "";
|
|
67
|
+
var _useState3 = useState(linkDataUrl),
|
|
68
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
69
|
+
newUrl = _useState4[0],
|
|
70
|
+
setNewUrl = _useState4[1];
|
|
71
|
+
useEffect(function () {
|
|
72
|
+
setNewUrl(linkDataUrl);
|
|
73
|
+
}, [linkDataUrl, setNewUrl]);
|
|
74
|
+
var handleClose = function handleClose() {
|
|
75
|
+
onClose();
|
|
76
|
+
};
|
|
77
|
+
var handleRemove = function handleRemove(e) {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
setNewUrl("");
|
|
80
|
+
var selection = editorState.getSelection();
|
|
81
|
+
if (!selection.isCollapsed()) {
|
|
82
|
+
onChange(RichUtils.toggleLink(editorState, selection, null));
|
|
83
|
+
}
|
|
84
|
+
onClose();
|
|
85
|
+
};
|
|
86
|
+
var handleUpdate = function handleUpdate(e) {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
var contentState = editorState.getCurrentContent();
|
|
89
|
+
var contentStateWithEntity = contentState.createEntity("LINK", "MUTABLE", {
|
|
90
|
+
url: newUrl
|
|
91
|
+
});
|
|
92
|
+
var entityKey = contentStateWithEntity.getLastCreatedEntityKey();
|
|
93
|
+
var newEditorState = EditorState.set(editorState, {
|
|
94
|
+
currentContent: contentStateWithEntity
|
|
95
|
+
});
|
|
96
|
+
onChange(RichUtils.toggleLink(newEditorState, newEditorState.getSelection(), entityKey));
|
|
97
|
+
onClose();
|
|
98
|
+
};
|
|
99
|
+
return /*#__PURE__*/_jsxs(Dialog, {
|
|
100
|
+
onClose: handleClose,
|
|
101
|
+
"aria-labelledby": "simple-dialog-title",
|
|
102
|
+
open: open,
|
|
103
|
+
children: [/*#__PURE__*/_jsx(DialogTitle, {
|
|
104
|
+
children: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
105
|
+
id: "comet.rte.extensions.link.editDialogTitle",
|
|
106
|
+
defaultMessage: "Link"
|
|
107
|
+
})
|
|
108
|
+
}), /*#__PURE__*/_jsx(DialogContent, {
|
|
109
|
+
children: /*#__PURE__*/_jsxs(FormControl, {
|
|
110
|
+
fullWidth: true,
|
|
111
|
+
children: [/*#__PURE__*/_jsx(FormLabel, {
|
|
112
|
+
children: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
113
|
+
id: "comet.rte.extensions.link.url",
|
|
114
|
+
defaultMessage: "URL"
|
|
115
|
+
})
|
|
116
|
+
}), /*#__PURE__*/_jsx(InputBase
|
|
117
|
+
// autoFocus
|
|
118
|
+
, {
|
|
119
|
+
value: newUrl,
|
|
120
|
+
onChange: function onChange(e) {
|
|
121
|
+
setNewUrl(e.target.value);
|
|
122
|
+
}
|
|
123
|
+
})]
|
|
124
|
+
})
|
|
125
|
+
}), /*#__PURE__*/_jsxs(DialogActions, {
|
|
126
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
127
|
+
onClick: handleClose,
|
|
128
|
+
variant: "outlined",
|
|
129
|
+
startIcon: /*#__PURE__*/_jsx(Close, {}),
|
|
130
|
+
children: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
131
|
+
id: "comet.generic.cancel",
|
|
132
|
+
defaultMessage: "Cancel"
|
|
133
|
+
})
|
|
134
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
135
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
|
136
|
+
container: true,
|
|
137
|
+
spacing: 4,
|
|
138
|
+
children: [linkData && /*#__PURE__*/_jsx(Grid, {
|
|
139
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
140
|
+
startIcon: /*#__PURE__*/_jsx(Delete, {}),
|
|
141
|
+
onClick: handleRemove,
|
|
142
|
+
children: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
143
|
+
id: "comet.generic.delete",
|
|
144
|
+
defaultMessage: "Delete"
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
}), /*#__PURE__*/_jsx(Grid, {
|
|
148
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
149
|
+
startIcon: /*#__PURE__*/_jsx(Check, {}),
|
|
150
|
+
onClick: handleUpdate,
|
|
151
|
+
disabled: !newUrl,
|
|
152
|
+
children: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
153
|
+
id: "comet.generic.save",
|
|
154
|
+
defaultMessage: "Save"
|
|
155
|
+
})
|
|
156
|
+
})
|
|
157
|
+
})]
|
|
158
|
+
})
|
|
159
|
+
})]
|
|
160
|
+
})]
|
|
161
|
+
});
|
|
162
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarButton.d.ts","sourceRoot":"","sources":["../../../../src/core/extension/LinksRemove/ToolbarButton.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAK,EAAE,aAAa,2CAazD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RteClearLink } from "@dextinity/admin-icons";
|
|
2
|
+
import { RichUtils } from "draft-js";
|
|
3
|
+
import { ControlButton } from "../../Controls/ControlButton";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
export default function ToolbarButton(props) {
|
|
6
|
+
var selection = props.editorState.getSelection();
|
|
7
|
+
var globallyDisabled = !!props.disabled;
|
|
8
|
+
var buttonEnabled = !selection.isCollapsed(); // @TODO: better to scan the selection if any link-entities are in the selection
|
|
9
|
+
function handleClick(e) {
|
|
10
|
+
e.preventDefault();
|
|
11
|
+
if (buttonEnabled) {
|
|
12
|
+
props.setEditorState(RichUtils.toggleLink(props.editorState, selection, null)); // @TODO, this removes all entities not only LINK entity, should be improved, now its ok as there are no other entities than links
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return /*#__PURE__*/_jsx(ControlButton, {
|
|
16
|
+
icon: RteClearLink,
|
|
17
|
+
disabled: globallyDisabled || !buttonEnabled,
|
|
18
|
+
onButtonClick: handleClick
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Decorator.d.ts","sourceRoot":"","sources":["../../../../src/core/extension/NonBreakingSpace/Decorator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAM/C,QAAA,MAAM,SAAS,EAAE,cAKhB,CAAC;AAWF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import EditorComponent from "./EditorComponent";
|
|
2
|
+
var NO_BREAK_SPACE_UNICODE_CHAR = /\u00a0/g;
|
|
3
|
+
var Decorator = {
|
|
4
|
+
strategy: function strategy(contentBlock, callback) {
|
|
5
|
+
findWithRegex(NO_BREAK_SPACE_UNICODE_CHAR, contentBlock, callback);
|
|
6
|
+
},
|
|
7
|
+
component: EditorComponent
|
|
8
|
+
};
|
|
9
|
+
function findWithRegex(regex, contentBlock, callback) {
|
|
10
|
+
var text = contentBlock.getText();
|
|
11
|
+
var matchArr, start;
|
|
12
|
+
while ((matchArr = regex.exec(text)) !== null) {
|
|
13
|
+
start = matchArr.index;
|
|
14
|
+
callback(start, start + matchArr[0].length);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export default Decorator;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ContentState } from "draft-js";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
interface Props {
|
|
4
|
+
contentState: ContentState;
|
|
5
|
+
entityKey: string;
|
|
6
|
+
}
|
|
7
|
+
declare const EditorComponent: ({ children }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default EditorComponent;
|
|
9
|
+
//# sourceMappingURL=EditorComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorComponent.d.ts","sourceRoot":"","sources":["../../../../src/core/extension/NonBreakingSpace/EditorComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,UAAU,KAAK;IACX,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,QAAA,MAAM,eAAe,GAAI,cAAc,iBAAiB,CAAC,KAAK,CAAC,4CAO9D,CAAC;AAkBF,eAAe,eAAe,CAAC"}
|