@procore/text-editor 0.0.1
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/.jest/ckeditorMock.js +67 -0
- package/.jest/esToolkitMock.js +23 -0
- package/.jest/setupTests.js +33 -0
- package/.jest/styleMock.js +1 -0
- package/.jest/svgTransform.js +10 -0
- package/.jest/translationFileMock.js +4 -0
- package/.jest/translationMock.js +12 -0
- package/LICENSE +84 -0
- package/README.md +107 -0
- package/codemod/__fixtures__/hammer.config.mjs +15 -0
- package/codemod/__fixtures__/jest.config.js +6 -0
- package/codemod/__fixtures__/procore.config.js +12 -0
- package/codemod/__fixtures__/src/components/ComplexEditor.tsx +21 -0
- package/codemod/__fixtures__/src/components/FormWithRichText.tsx +10 -0
- package/codemod/__fixtures__/src/components/MultilineFormRichText.tsx +14 -0
- package/codemod/__fixtures__/src/components/NoTextEditor.tsx +11 -0
- package/codemod/__fixtures__/src/components/ReadOnlyRichText.tsx +10 -0
- package/codemod/__fixtures__/src/components/SimpleEditor.tsx +11 -0
- package/codemod/__fixtures__/src/components/TypeImportEditor.tsx +17 -0
- package/codemod/text-editor-migrate.js +509 -0
- package/codemod/text-editor-migrate.test.js +225 -0
- package/dist/TextEditor/EditorError.js +9 -0
- package/dist/TextEditor/EditorError.js.map +1 -0
- package/dist/TextEditor/StickyToolbar/index.js +2 -0
- package/dist/TextEditor/StickyToolbar/index.js.map +1 -0
- package/dist/TextEditor/StickyToolbar/useStickyToolbar.js +59 -0
- package/dist/TextEditor/StickyToolbar/useStickyToolbar.js.map +1 -0
- package/dist/TextEditor/StickyToolbar/useStickyToolbar.types.js +2 -0
- package/dist/TextEditor/StickyToolbar/useStickyToolbar.types.js.map +1 -0
- package/dist/TextEditor/TextEditor.js +226 -0
- package/dist/TextEditor/TextEditor.js.map +1 -0
- package/dist/TextEditor/TextEditor.styles.js +26 -0
- package/dist/TextEditor/TextEditor.styles.js.map +1 -0
- package/dist/TextEditor/TextEditor.types.js +2 -0
- package/dist/TextEditor/TextEditor.types.js.map +1 -0
- package/dist/TextEditor/TextEditorProvider.js +17 -0
- package/dist/TextEditor/TextEditorProvider.js.map +1 -0
- package/dist/TextEditor/TextEditorProvider.types.js +2 -0
- package/dist/TextEditor/TextEditorProvider.types.js.map +1 -0
- package/dist/TextEditor/index.js +4 -0
- package/dist/TextEditor/index.js.map +1 -0
- package/dist/TextEditor/license_key.js +3 -0
- package/dist/TextEditor/license_key.js.map +1 -0
- package/dist/TextEditor/plugins/CutPlugin/CutCommand.js +99 -0
- package/dist/TextEditor/plugins/CutPlugin/CutCommand.js.map +1 -0
- package/dist/TextEditor/plugins/CutPlugin/CutPlugin.js +56 -0
- package/dist/TextEditor/plugins/CutPlugin/CutPlugin.js.map +1 -0
- package/dist/TextEditor/plugins/CutPlugin/index.js +2 -0
- package/dist/TextEditor/plugins/CutPlugin/index.js.map +1 -0
- package/dist/TextEditor/plugins/IndentPaddingToMarginPlugin/IndentPaddingToMarginPlugin.js +40 -0
- package/dist/TextEditor/plugins/IndentPaddingToMarginPlugin/IndentPaddingToMarginPlugin.js.map +1 -0
- package/dist/TextEditor/plugins/IndentPaddingToMarginPlugin/index.js +2 -0
- package/dist/TextEditor/plugins/IndentPaddingToMarginPlugin/index.js.map +1 -0
- package/dist/TextEditor/plugins/PasteAsTextPlugin/PasteAsTextCommand.js +86 -0
- package/dist/TextEditor/plugins/PasteAsTextPlugin/PasteAsTextCommand.js.map +1 -0
- package/dist/TextEditor/plugins/PasteAsTextPlugin/PasteAsTextPlugin.js +56 -0
- package/dist/TextEditor/plugins/PasteAsTextPlugin/PasteAsTextPlugin.js.map +1 -0
- package/dist/TextEditor/plugins/PasteAsTextPlugin/index.js +2 -0
- package/dist/TextEditor/plugins/PasteAsTextPlugin/index.js.map +1 -0
- package/dist/TextEditor/plugins/PastePlugin/PasteCommand.js +149 -0
- package/dist/TextEditor/plugins/PastePlugin/PasteCommand.js.map +1 -0
- package/dist/TextEditor/plugins/PastePlugin/PastePlugin.js +56 -0
- package/dist/TextEditor/plugins/PastePlugin/PastePlugin.js.map +1 -0
- package/dist/TextEditor/plugins/PastePlugin/index.js +2 -0
- package/dist/TextEditor/plugins/PastePlugin/index.js.map +1 -0
- package/dist/TextEditor/plugins/TabSpacesPlugin/TabSpacesPlugin.js +87 -0
- package/dist/TextEditor/plugins/TabSpacesPlugin/TabSpacesPlugin.js.map +1 -0
- package/dist/TextEditor/plugins/TabSpacesPlugin/index.js +2 -0
- package/dist/TextEditor/plugins/TabSpacesPlugin/index.js.map +1 -0
- package/dist/TextEditor/textEditorTheming/icons.js +24 -0
- package/dist/TextEditor/textEditorTheming/icons.js.map +1 -0
- package/dist/TextEditor/textEditorTheming/index.js +2 -0
- package/dist/TextEditor/textEditorTheming/index.js.map +1 -0
- package/dist/TextEditor/textEditorTheming/textEditorTheming.styles.js +10 -0
- package/dist/TextEditor/textEditorTheming/textEditorTheming.styles.js.map +1 -0
- package/dist/TextEditor/useCKEditorCss.js +36 -0
- package/dist/TextEditor/useCKEditorCss.js.map +1 -0
- package/dist/TextEditor/useTabAsNavigation.js +29 -0
- package/dist/TextEditor/useTabAsNavigation.js.map +1 -0
- package/dist/TextEditor/utils/config.js +179 -0
- package/dist/TextEditor/utils/config.js.map +1 -0
- package/dist/TextEditor/utils/index.js +3 -0
- package/dist/TextEditor/utils/index.js.map +1 -0
- package/dist/TextEditor/utils/locale.js +102 -0
- package/dist/TextEditor/utils/locale.js.map +1 -0
- package/dist/TextEditor/utils/plugins.js +184 -0
- package/dist/TextEditor/utils/plugins.js.map +1 -0
- package/dist/TextEditorOutput/TextEditorOutput.js +29 -0
- package/dist/TextEditorOutput/TextEditorOutput.js.map +1 -0
- package/dist/TextEditorOutput/TextEditorOutput.styles.js +6 -0
- package/dist/TextEditorOutput/TextEditorOutput.styles.js.map +1 -0
- package/dist/TextEditorOutput/TextEditorOutput.types.js +2 -0
- package/dist/TextEditorOutput/TextEditorOutput.types.js.map +1 -0
- package/dist/TextEditorOutput/TextEditorOutput.utils.js +59 -0
- package/dist/TextEditorOutput/TextEditorOutput.utils.js.map +1 -0
- package/dist/TextEditorOutput/index.js +2 -0
- package/dist/TextEditorOutput/index.js.map +1 -0
- package/dist/_storyHelpers/constants.js +48 -0
- package/dist/_storyHelpers/constants.js.map +1 -0
- package/dist/_typedoc/TextEditor/TextEditor.types.json +227 -0
- package/dist/_typedoc/TextEditor/TextEditorProvider.types.json +28 -0
- package/dist/_typedoc/TextEditorOutput/TextEditorOutput.types.json +38 -0
- package/dist/_typedoc/deprecations.json +1 -0
- package/dist/_utils/propsTypedoc.js +4 -0
- package/dist/_utils/propsTypedoc.js.map +1 -0
- package/dist/codemod/__fixtures__/src/components/ComplexEditor.d.ts +2 -0
- package/dist/codemod/__fixtures__/src/components/FormWithRichText.d.ts +2 -0
- package/dist/codemod/__fixtures__/src/components/MultilineFormRichText.d.ts +2 -0
- package/dist/codemod/__fixtures__/src/components/NoTextEditor.d.ts +2 -0
- package/dist/codemod/__fixtures__/src/components/ReadOnlyRichText.d.ts +2 -0
- package/dist/codemod/__fixtures__/src/components/SimpleEditor.d.ts +2 -0
- package/dist/codemod/__fixtures__/src/components/TypeImportEditor.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/src/TextEditor/EditorError.d.ts +2 -0
- package/dist/src/TextEditor/StickyToolbar/index.d.ts +2 -0
- package/dist/src/TextEditor/StickyToolbar/useStickyToolbar.d.ts +2 -0
- package/dist/src/TextEditor/StickyToolbar/useStickyToolbar.types.d.ts +8 -0
- package/dist/src/TextEditor/TextEditor.d.ts +44 -0
- package/dist/src/TextEditor/TextEditor.styles.d.ts +7 -0
- package/dist/src/TextEditor/TextEditor.types.d.ts +155 -0
- package/dist/src/TextEditor/TextEditorProvider.d.ts +4 -0
- package/dist/src/TextEditor/TextEditorProvider.types.d.ts +14 -0
- package/dist/src/TextEditor/index.d.ts +4 -0
- package/dist/src/TextEditor/license_key.d.ts +2 -0
- package/dist/src/TextEditor/plugins/CutPlugin/CutCommand.d.ts +5 -0
- package/dist/src/TextEditor/plugins/CutPlugin/CutPlugin.d.ts +5 -0
- package/dist/src/TextEditor/plugins/CutPlugin/index.d.ts +1 -0
- package/dist/src/TextEditor/plugins/IndentPaddingToMarginPlugin/IndentPaddingToMarginPlugin.d.ts +5 -0
- package/dist/src/TextEditor/plugins/IndentPaddingToMarginPlugin/index.d.ts +1 -0
- package/dist/src/TextEditor/plugins/PasteAsTextPlugin/PasteAsTextCommand.d.ts +5 -0
- package/dist/src/TextEditor/plugins/PasteAsTextPlugin/PasteAsTextPlugin.d.ts +5 -0
- package/dist/src/TextEditor/plugins/PasteAsTextPlugin/index.d.ts +1 -0
- package/dist/src/TextEditor/plugins/PastePlugin/PasteCommand.d.ts +5 -0
- package/dist/src/TextEditor/plugins/PastePlugin/PastePlugin.d.ts +5 -0
- package/dist/src/TextEditor/plugins/PastePlugin/index.d.ts +1 -0
- package/dist/src/TextEditor/plugins/TabSpacesPlugin/TabSpacesPlugin.d.ts +6 -0
- package/dist/src/TextEditor/plugins/TabSpacesPlugin/index.d.ts +1 -0
- package/dist/src/TextEditor/textEditorTheming/icons.d.ts +23 -0
- package/dist/src/TextEditor/textEditorTheming/index.d.ts +1 -0
- package/dist/src/TextEditor/textEditorTheming/textEditorTheming.styles.d.ts +2 -0
- package/dist/src/TextEditor/useCKEditorCss.d.ts +3 -0
- package/dist/src/TextEditor/useTabAsNavigation.d.ts +11 -0
- package/dist/src/TextEditor/utils/config.d.ts +3 -0
- package/dist/src/TextEditor/utils/index.d.ts +2 -0
- package/dist/src/TextEditor/utils/locale.d.ts +3 -0
- package/dist/src/TextEditor/utils/plugins.d.ts +7 -0
- package/dist/src/TextEditorOutput/TextEditorOutput.d.ts +8 -0
- package/dist/src/TextEditorOutput/TextEditorOutput.styles.d.ts +2 -0
- package/dist/src/TextEditorOutput/TextEditorOutput.types.d.ts +21 -0
- package/dist/src/TextEditorOutput/TextEditorOutput.utils.d.ts +2 -0
- package/dist/src/TextEditorOutput/index.d.ts +2 -0
- package/dist/src/_storyHelpers/constants.d.ts +14 -0
- package/dist/src/_utils/propsTypedoc.d.ts +3 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/stories/util.d.ts +21 -0
- package/dist/stories/util.js +86 -0
- package/dist/stories/util.js.map +1 -0
- package/jestConfig.d.ts +1 -0
- package/jestConfig.js +66 -0
- package/package.json +146 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createGlobalStyle } from 'styled-components';
|
|
2
|
+
import { alignCenterIcon, alignLeftIcon, alignRightIcon, bgColorIcon, boldIcon, checkmarkIcon, cutIcon, fontSizeIcon, imageIcon, indentIcon, italicIcon, linkIcon, orderedListIcon, outdentIcon, pasteAsTextIcon, pasteIcon, redoIcon, strikeThroughIcon, tableIcon, textColorIcon, underlineIcon, undoIcon, unorderedListIcon } from './icons';
|
|
3
|
+
var getIconUrl = function getIconUrl(icon) {
|
|
4
|
+
if (icon.startsWith('data:')) {
|
|
5
|
+
return icon;
|
|
6
|
+
}
|
|
7
|
+
return "data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(icon));
|
|
8
|
+
};
|
|
9
|
+
export var TextEditorTheme = /*#__PURE__*/createGlobalStyle([".ck-button:first-child .ck-icon:first-child{background-size:24px;background-repeat:no-repeat;background-position:center;}[data-cke-command=\"bold\"],[data-cke-command=\"italic\"],[data-cke-command=\"underline\"],[data-cke-command=\"strikethrough\"],[data-cke-command=\"alignment:left\"],[data-cke-command=\"alignment:center\"],[data-cke-command=\"alignment:right\"],[data-cke-command=\"bulletedList\"],[data-cke-command=\"numberedList\"],[data-cke-command=\"outdent\"],[data-cke-command=\"indent\"],[data-cke-command=\"cut\"],[data-cke-command=\"paste\"],[data-cke-command=\"pasteAsText\"],[data-cke-command=\"fontSize\"],[data-cke-command=\"fontColor\"],[data-cke-command=\"fontBackgroundColor\"],[data-cke-command=\"link\"],[data-cke-command=\"insertTable\"],[data-cke-command=\"insertImageViaUrl\"],[data-cke-command=\"undo\"],[data-cke-command=\"redo\"]{> .ck-icon:first-child > *,> .ck-button:first-child > .ck-icon:first-child > *,> .ck-splitbutton > .ck-button:first-child > .ck-icon:first-child > *{display:none;}> .ck-icon:first-child,> .ck-splitbutton > .ck-button:first-child .ck-icon:first-child,> .ck-button > .ck-icon:first-child{width:24px !important;height:24px !important;}}[data-cke-command=\"bold\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"italic\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"underline\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"strikethrough\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"alignment:left\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"alignment:center\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"alignment:right\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"bulletedList\"] > .ck-splitbutton > .ck-button:first-child .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"numberedList\"] > .ck-splitbutton > .ck-button:first-child .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"outdent\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"indent\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"cut\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"paste\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"pasteAsText\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"fontSize\"] > .ck-button > .ck-icon:first-child{background-image:url('", "');background-size:19px;}[data-cke-command=\"fontColor\"] > .ck-button > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"fontBackgroundColor\"] > .ck-button > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"link\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"insertTable\"] > .ck-button > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"insertImageViaUrl\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"undo\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"redo\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"fontSize\"] .ck-dropdown__panel{max-width:130px !important;.ck-list__item{min-width:128px !important;}.ck-list{.ck-button{padding:4px 12px !important;font-size:14px !important;line-height:24px !important;.ck-button__label{font-size:14px !important;font-weight:normal !important;font-family:inherit !important;line-height:24px !important;}&[data-cke-tooltip-text]{font-size:14px !important;.ck-button__label{font-size:14px !important;}}&.ck-on{position:relative;padding-right:32px !important;&::after{content:\"\";position:absolute;right:8px;top:50%;transform:translateY(-50%);width:24px !important;height:24px !important;background-image:url('", "');background-size:24px 24px;background-repeat:no-repeat;background-position:center;line-height:1;}}}}.ck-list-item-button__check-holder{display:none !important;}}"], getIconUrl(boldIcon), getIconUrl(italicIcon), getIconUrl(underlineIcon), getIconUrl(strikeThroughIcon), getIconUrl(alignLeftIcon), getIconUrl(alignCenterIcon), getIconUrl(alignRightIcon), getIconUrl(unorderedListIcon), getIconUrl(orderedListIcon), getIconUrl(outdentIcon), getIconUrl(indentIcon), getIconUrl(cutIcon), getIconUrl(pasteIcon), getIconUrl(pasteAsTextIcon), getIconUrl(fontSizeIcon), getIconUrl(textColorIcon), getIconUrl(bgColorIcon), getIconUrl(linkIcon), getIconUrl(tableIcon), getIconUrl(imageIcon), getIconUrl(undoIcon), getIconUrl(redoIcon), getIconUrl(checkmarkIcon));
|
|
10
|
+
//# sourceMappingURL=textEditorTheming.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textEditorTheming.styles.js","names":["createGlobalStyle","alignCenterIcon","alignLeftIcon","alignRightIcon","bgColorIcon","boldIcon","checkmarkIcon","cutIcon","fontSizeIcon","imageIcon","indentIcon","italicIcon","linkIcon","orderedListIcon","outdentIcon","pasteAsTextIcon","pasteIcon","redoIcon","strikeThroughIcon","tableIcon","textColorIcon","underlineIcon","undoIcon","unorderedListIcon","getIconUrl","icon","startsWith","concat","encodeURIComponent","TextEditorTheme"],"sources":["../../../src/TextEditor/textEditorTheming/textEditorTheming.styles.ts"],"sourcesContent":["import { createGlobalStyle } from 'styled-components'\nimport {\n alignCenterIcon,\n alignLeftIcon,\n alignRightIcon,\n bgColorIcon,\n boldIcon,\n checkmarkIcon,\n cutIcon,\n fontSizeIcon,\n imageIcon,\n indentIcon,\n italicIcon,\n linkIcon,\n orderedListIcon,\n outdentIcon,\n pasteAsTextIcon,\n pasteIcon,\n redoIcon,\n strikeThroughIcon,\n tableIcon,\n textColorIcon,\n underlineIcon,\n undoIcon,\n unorderedListIcon,\n} from './icons'\n\nconst getIconUrl = (icon: string) => {\n if (icon.startsWith('data:')) {\n return icon\n }\n return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(icon)}`\n}\n\nexport const TextEditorTheme = createGlobalStyle`\n .ck-button:first-child .ck-icon:first-child {\n background-size: 24px;\n background-repeat: no-repeat;\n background-position: center;\n }\n\n [data-cke-command=\"bold\"],\n [data-cke-command=\"italic\"],\n [data-cke-command=\"underline\"],\n [data-cke-command=\"strikethrough\"],\n [data-cke-command=\"alignment:left\"],\n [data-cke-command=\"alignment:center\"],\n [data-cke-command=\"alignment:right\"],\n [data-cke-command=\"bulletedList\"],\n [data-cke-command=\"numberedList\"],\n [data-cke-command=\"outdent\"],\n [data-cke-command=\"indent\"],\n [data-cke-command=\"cut\"],\n [data-cke-command=\"paste\"],\n [data-cke-command=\"pasteAsText\"],\n [data-cke-command=\"fontSize\"],\n [data-cke-command=\"fontColor\"],\n [data-cke-command=\"fontBackgroundColor\"],\n [data-cke-command=\"link\"],\n [data-cke-command=\"insertTable\"],\n [data-cke-command=\"insertImageViaUrl\"],\n [data-cke-command=\"undo\"],\n [data-cke-command=\"redo\"] {\n > .ck-icon:first-child > *,\n > .ck-button:first-child > .ck-icon:first-child > *,\n > .ck-splitbutton > .ck-button:first-child > .ck-icon:first-child > * {\n display: none;\n }\n\n > .ck-icon:first-child,\n > .ck-splitbutton > .ck-button:first-child .ck-icon:first-child,\n > .ck-button > .ck-icon:first-child {\n width: 24px !important;\n height: 24px !important;\n }\n }\n\n [data-cke-command=\"bold\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(boldIcon)}');\n }\n\n [data-cke-command=\"italic\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(italicIcon)}');\n }\n\n [data-cke-command=\"underline\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(underlineIcon)}');\n }\n\n [data-cke-command=\"strikethrough\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(strikeThroughIcon)}');\n }\n\n [data-cke-command=\"alignment:left\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(alignLeftIcon)}');\n }\n\n [data-cke-command=\"alignment:center\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(alignCenterIcon)}');\n }\n\n [data-cke-command=\"alignment:right\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(alignRightIcon)}');\n }\n\n [data-cke-command=\"bulletedList\"] > .ck-splitbutton > .ck-button:first-child .ck-icon:first-child {\n background-image: url('${getIconUrl(unorderedListIcon)}');\n }\n\n [data-cke-command=\"numberedList\"] > .ck-splitbutton > .ck-button:first-child .ck-icon:first-child {\n background-image: url('${getIconUrl(orderedListIcon)}');\n }\n\n [data-cke-command=\"outdent\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(outdentIcon)}');\n }\n\n [data-cke-command=\"indent\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(indentIcon)}');\n }\n\n [data-cke-command=\"cut\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(cutIcon)}');\n }\n\n [data-cke-command=\"paste\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(pasteIcon)}');\n }\n\n [data-cke-command=\"pasteAsText\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(pasteAsTextIcon)}');\n }\n\n [data-cke-command=\"fontSize\"] > .ck-button > .ck-icon:first-child {\n background-image: url('${getIconUrl(fontSizeIcon)}');\n background-size: 19px;\n }\n\n [data-cke-command=\"fontColor\"] > .ck-button > .ck-icon:first-child {\n background-image: url('${getIconUrl(textColorIcon)}');\n }\n\n [data-cke-command=\"fontBackgroundColor\"] > .ck-button > .ck-icon:first-child {\n background-image: url('${getIconUrl(bgColorIcon)}');\n }\n [data-cke-command=\"link\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(linkIcon)}');\n }\n\n [data-cke-command=\"insertTable\"] > .ck-button > .ck-icon:first-child {\n background-image: url('${getIconUrl(tableIcon)}');\n }\n\n [data-cke-command=\"insertImageViaUrl\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(imageIcon)}');\n }\n\n [data-cke-command=\"undo\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(undoIcon)}');\n }\n\n [data-cke-command=\"redo\"] > .ck-icon:first-child {\n background-image: url('${getIconUrl(redoIcon)}');\n }\n\n [data-cke-command=\"fontSize\"] .ck-dropdown__panel {\n max-width: 130px !important;\n\n .ck-list__item {\n min-width: 128px !important;\n }\n\n .ck-list {\n .ck-button {\n padding: 4px 12px !important;\n font-size: 14px !important;\n line-height: 24px !important;\n\n .ck-button__label {\n font-size: 14px !important;\n font-weight: normal !important;\n font-family: inherit !important;\n line-height: 24px !important;\n }\n\n &[data-cke-tooltip-text] {\n font-size: 14px !important;\n\n .ck-button__label {\n font-size: 14px !important;\n }\n }\n\n &.ck-on {\n position: relative;\n padding-right: 32px !important;\n\n &::after {\n content: \"\";\n position: absolute;\n right: 8px;\n top: 50%;\n transform: translateY(-50%);\n width: 24px !important;\n height: 24px !important;\n background-image: url('${getIconUrl(checkmarkIcon)}');\n background-size: 24px 24px;\n background-repeat: no-repeat;\n background-position: center;\n line-height: 1;\n }\n }\n }\n }\n\n .ck-list-item-button__check-holder {\n display: none !important;\n }\n }\n`\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,mBAAmB;AACrD,SACEC,eAAe,EACfC,aAAa,EACbC,cA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pBE,UAAU,CAACP,QAAQ,CAAC,EA2CZO,UAAU,CAAClB,aAAa,CAAC,CAc7D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { useEffect, useState } from 'react';
|
|
8
|
+
var CKEDITOR_CSS_URL = 'https://cdn.ckeditor.com/ckeditor5/46.0.1/ckeditor5.css';
|
|
9
|
+
var CKEDITOR_CSS_ID = 'ckeditor-styles';
|
|
10
|
+
export var useCKEditorCss = function useCKEditorCss() {
|
|
11
|
+
var _useState = useState(true),
|
|
12
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
13
|
+
isLoading = _useState2[0],
|
|
14
|
+
setIsLoading = _useState2[1];
|
|
15
|
+
useEffect(function () {
|
|
16
|
+
if (document.getElementById(CKEDITOR_CSS_ID)) {
|
|
17
|
+
setIsLoading(false);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
var link = document.createElement('link');
|
|
21
|
+
link.id = CKEDITOR_CSS_ID;
|
|
22
|
+
link.href = CKEDITOR_CSS_URL;
|
|
23
|
+
link.rel = 'stylesheet';
|
|
24
|
+
link.onload = function () {
|
|
25
|
+
setIsLoading(false);
|
|
26
|
+
};
|
|
27
|
+
link.onerror = function () {
|
|
28
|
+
setIsLoading(false);
|
|
29
|
+
};
|
|
30
|
+
document.head.appendChild(link);
|
|
31
|
+
}, []);
|
|
32
|
+
return {
|
|
33
|
+
isLoading: isLoading
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=useCKEditorCss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCKEditorCss.js","names":["useEffect","useState","CKEDITOR_CSS_URL","CKEDITOR_CSS_ID","useCKEditorCss","_useState","_useState2","_slicedToArray","isLoading","setIsLoading","document","getElementById","link","createElement","id","href","rel","onload","onerror","head","appendChild"],"sources":["../../src/TextEditor/useCKEditorCss.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\nconst CKEDITOR_CSS_URL =\n 'https://cdn.ckeditor.com/ckeditor5/46.0.1/ckeditor5.css'\nconst CKEDITOR_CSS_ID = 'ckeditor-styles'\n\nexport const useCKEditorCss = () => {\n const [isLoading, setIsLoading] = useState(true)\n\n useEffect(() => {\n if (document.getElementById(CKEDITOR_CSS_ID)) {\n setIsLoading(false)\n return\n }\n\n const link = document.createElement('link')\n link.id = CKEDITOR_CSS_ID\n link.href = CKEDITOR_CSS_URL\n link.rel = 'stylesheet'\n\n link.onload = () => {\n setIsLoading(false)\n }\n\n link.onerror = () => {\n setIsLoading(false)\n }\n\n document.head.appendChild(link)\n }, [])\n\n return { isLoading }\n}\n"],"mappings":";;;;;;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,IAAMC,gBAAgB,GACpB,yDAAyD;AAC3D,IAAMC,eAAe,GAAG,iBAAiB;AAEzC,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAA,EAAS;EAClC,IAAAC,SAAA,GAAkCJ,QAAQ,CAAC,IAAI,CAAC;IAAAK,UAAA,GAAAC,cAAA,CAAAF,SAAA;IAAzCG,SAAS,GAAAF,UAAA;IAAEG,YAAY,GAAAH,UAAA;EAE9BN,SAAS,CAAC,YAAM;IACd,IAAIU,QAAQ,CAACC,cAAc,CAACR,eAAe,CAAC,EAAE;MAC5CM,YAAY,CAAC,KAAK,CAAC;MACnB;IACF;IAEA,IAAMG,IAAI,GAAGF,QAAQ,CAACG,aAAa,CAAC,MAAM,CAAC;IAC3CD,IAAI,CAACE,EAAE,GAAGX,eAAe;IACzBS,IAAI,CAACG,IAAI,GAAGb,gBAAgB;IAC5BU,IAAI,CAACI,GAAG,GAAG,YAAY;IAEvBJ,IAAI,CAACK,MAAM,GAAG,YAAM;MAClBR,YAAY,CAAC,KAAK,CAAC;IACrB,CAAC;IAEDG,IAAI,CAACM,OAAO,GAAG,YAAM;MACnBT,YAAY,CAAC,KAAK,CAAC;IACrB,CAAC;IAEDC,QAAQ,CAACS,IAAI,CAACC,WAAW,CAACR,IAAI,CAAC;EACjC,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IAAEJ,SAAS,EAATA;EAAU,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 React from 'react';
|
|
8
|
+
export var useTabAsNavigation = function useTabAsNavigation(_ref) {
|
|
9
|
+
var enabled = _ref.enabled,
|
|
10
|
+
config = _ref.config,
|
|
11
|
+
editor = _ref.editor;
|
|
12
|
+
var enhancedConfig = React.useMemo(function () {
|
|
13
|
+
if (!enabled || !config.plugins) {
|
|
14
|
+
return config;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Remove TabSpacesPlugin when tabAsNavigation is enabled
|
|
18
|
+
var filteredPlugins = config.plugins.filter(function (plugin) {
|
|
19
|
+
return typeof plugin === 'string' ? plugin !== 'TabSpacesPlugin' : plugin.pluginName !== 'TabSpacesPlugin';
|
|
20
|
+
});
|
|
21
|
+
return _objectSpread(_objectSpread({}, config), {}, {
|
|
22
|
+
plugins: filteredPlugins
|
|
23
|
+
});
|
|
24
|
+
}, [enabled, config]);
|
|
25
|
+
return {
|
|
26
|
+
config: enhancedConfig
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=useTabAsNavigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTabAsNavigation.js","names":["React","useTabAsNavigation","_ref","enabled","config","editor","enhancedConfig","useMemo","plugins","filteredPlugins","filter","plugin","pluginName","_objectSpread"],"sources":["../../src/TextEditor/useTabAsNavigation.ts"],"sourcesContent":["import type { ClassicEditor, EditorConfig } from 'ckeditor5'\nimport React from 'react'\n\ninterface UseTabAsNavigationProps {\n enabled: boolean\n config: EditorConfig\n editor: ClassicEditor | null\n}\n\ninterface UseTabAsNavigationReturn {\n config: EditorConfig\n}\n\nexport const useTabAsNavigation = ({\n enabled,\n config,\n editor,\n}: UseTabAsNavigationProps): UseTabAsNavigationReturn => {\n const enhancedConfig = React.useMemo(() => {\n if (!enabled || !config.plugins) {\n return config\n }\n\n // Remove TabSpacesPlugin when tabAsNavigation is enabled\n const filteredPlugins = config.plugins.filter((plugin) => {\n return typeof plugin === 'string'\n ? plugin !== 'TabSpacesPlugin'\n : plugin.pluginName !== 'TabSpacesPlugin'\n })\n\n return {\n ...config,\n plugins: filteredPlugins,\n }\n }, [enabled, config])\n\n return { config: enhancedConfig }\n}\n"],"mappings":";;;;;;AACA,OAAOA,KAAK,MAAM,OAAO;AAYzB,OAAO,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAAC,IAAA,EAI0B;EAAA,IAHvDC,OAAO,GAAAD,IAAA,CAAPC,OAAO;IACPC,MAAM,GAAAF,IAAA,CAANE,MAAM;IACNC,MAAM,GAAAH,IAAA,CAANG,MAAM;EAEN,IAAMC,cAAc,GAAGN,KAAK,CAACO,OAAO,CAAC,YAAM;IACzC,IAAI,CAACJ,OAAO,IAAI,CAACC,MAAM,CAACI,OAAO,EAAE;MAC/B,OAAOJ,MAAM;IACf;;IAEA;IACA,IAAMK,eAAe,GAAGL,MAAM,CAACI,OAAO,CAACE,MAAM,CAAC,UAACC,MAAM,EAAK;MACxD,OAAO,OAAOA,MAAM,KAAK,QAAQ,GAC7BA,MAAM,KAAK,iBAAiB,GAC5BA,MAAM,CAACC,UAAU,KAAK,iBAAiB;IAC7C,CAAC,CAAC;IAEF,OAAAC,aAAA,CAAAA,aAAA,KACKT,MAAM;MACTI,OAAO,EAAEC;IAAe;EAE5B,CAAC,EAAE,CAACN,OAAO,EAAEC,MAAM,CAAC,CAAC;EAErB,OAAO;IAAEA,MAAM,EAAEE;EAAe,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { Alignment, AutoLink, Bold, Clipboard, Essentials, FontBackgroundColor, FontColor, FontSize, GeneralHtmlSupport, Image, ImageInsert, ImageToolbar, Indent, IndentBlock, Italic, Link, List, ListProperties, Paragraph, Strikethrough, Table, TableCaption, TableCellProperties, TableColumnResize, TableProperties, TableToolbar, Underline } from 'ckeditor5';
|
|
2
|
+
import { CK_EDITOR_LICENSE_KEY } from '../license_key';
|
|
3
|
+
import { CutPlugin } from '../plugins/CutPlugin';
|
|
4
|
+
import { IndentPaddingToMarginPlugin } from '../plugins/IndentPaddingToMarginPlugin';
|
|
5
|
+
import { PasteAsTextPlugin } from '../plugins/PasteAsTextPlugin';
|
|
6
|
+
import { PastePlugin } from '../plugins/PastePlugin';
|
|
7
|
+
import { TabSpacesPlugin } from '../plugins/TabSpacesPlugin';
|
|
8
|
+
import { getEditorTranslation, getValidEditorLocale } from './locale';
|
|
9
|
+
var TEXT_COLOR_PALETTE = [{
|
|
10
|
+
color: '#BFEDD2'
|
|
11
|
+
}, {
|
|
12
|
+
color: '#FBEEB8'
|
|
13
|
+
}, {
|
|
14
|
+
color: '#F8CAC6'
|
|
15
|
+
}, {
|
|
16
|
+
color: '#ECCAFA'
|
|
17
|
+
}, {
|
|
18
|
+
color: '#C2E0F4'
|
|
19
|
+
}, {
|
|
20
|
+
color: '#2DC26B'
|
|
21
|
+
}, {
|
|
22
|
+
color: '#F1C40F'
|
|
23
|
+
}, {
|
|
24
|
+
color: '#E03E2D'
|
|
25
|
+
}, {
|
|
26
|
+
color: '#B96AD9'
|
|
27
|
+
}, {
|
|
28
|
+
color: '#3598DB'
|
|
29
|
+
}, {
|
|
30
|
+
color: '#169179'
|
|
31
|
+
}, {
|
|
32
|
+
color: '#E67E23'
|
|
33
|
+
}, {
|
|
34
|
+
color: '#BA372A'
|
|
35
|
+
}, {
|
|
36
|
+
color: '#843FA1'
|
|
37
|
+
}, {
|
|
38
|
+
color: '#236FA1'
|
|
39
|
+
}, {
|
|
40
|
+
color: '#ECF0F1'
|
|
41
|
+
}, {
|
|
42
|
+
color: '#CED4D9'
|
|
43
|
+
}, {
|
|
44
|
+
color: '#95A5A6'
|
|
45
|
+
}, {
|
|
46
|
+
color: '#7E8C8D'
|
|
47
|
+
}, {
|
|
48
|
+
color: '#34495E'
|
|
49
|
+
}, {
|
|
50
|
+
color: '#000000'
|
|
51
|
+
}, {
|
|
52
|
+
color: '#FFFFFF'
|
|
53
|
+
}];
|
|
54
|
+
export var getDefaultConfig = function getDefaultConfig() {
|
|
55
|
+
var locale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'en';
|
|
56
|
+
return {
|
|
57
|
+
licenseKey: CK_EDITOR_LICENSE_KEY,
|
|
58
|
+
language: getValidEditorLocale(locale),
|
|
59
|
+
translations: [getEditorTranslation(locale)],
|
|
60
|
+
plugins: [Alignment, AutoLink, Bold, Clipboard, Essentials, FontBackgroundColor, FontColor, FontSize, GeneralHtmlSupport, Indent, IndentBlock, Italic, Link, List, ListProperties, Paragraph, Strikethrough, Table, TableCaption, TableCellProperties, TableColumnResize, TableProperties, TableToolbar, Underline, Image, ImageInsert, ImageToolbar, CutPlugin, PastePlugin, PasteAsTextPlugin, IndentPaddingToMarginPlugin, TabSpacesPlugin],
|
|
61
|
+
toolbar: ['bold', 'italic', 'underline', 'strikethrough', '|', 'alignment:left', 'alignment:center', 'alignment:right', '|', 'bulletedList', 'numberedList', '|', 'outdent', 'indent', '|', 'cut', 'paste', 'pasteAsText', '|', 'fontSize', '|', 'fontColor', 'fontBackgroundColor', '|', 'undo', 'redo'],
|
|
62
|
+
fontSize: {
|
|
63
|
+
options: [{
|
|
64
|
+
title: '8pt',
|
|
65
|
+
model: '8px'
|
|
66
|
+
}, {
|
|
67
|
+
title: '10pt',
|
|
68
|
+
model: '10px'
|
|
69
|
+
}, {
|
|
70
|
+
title: '12pt',
|
|
71
|
+
model: '12px'
|
|
72
|
+
}, {
|
|
73
|
+
title: '14pt',
|
|
74
|
+
model: '14px'
|
|
75
|
+
}, {
|
|
76
|
+
title: '18pt',
|
|
77
|
+
model: '18px'
|
|
78
|
+
}, {
|
|
79
|
+
title: '24pt',
|
|
80
|
+
model: '24px'
|
|
81
|
+
}, {
|
|
82
|
+
title: '36pt',
|
|
83
|
+
model: '36px'
|
|
84
|
+
}],
|
|
85
|
+
supportAllValues: true
|
|
86
|
+
},
|
|
87
|
+
fontColor: {
|
|
88
|
+
colors: TEXT_COLOR_PALETTE
|
|
89
|
+
},
|
|
90
|
+
fontBackgroundColor: {
|
|
91
|
+
colors: TEXT_COLOR_PALETTE
|
|
92
|
+
},
|
|
93
|
+
indentBlock: {
|
|
94
|
+
offset: 40,
|
|
95
|
+
unit: 'px'
|
|
96
|
+
},
|
|
97
|
+
htmlSupport: {
|
|
98
|
+
allow: [{
|
|
99
|
+
name: 'p',
|
|
100
|
+
styles: {
|
|
101
|
+
'margin-left': true
|
|
102
|
+
}
|
|
103
|
+
}]
|
|
104
|
+
},
|
|
105
|
+
list: {
|
|
106
|
+
properties: {
|
|
107
|
+
styles: {
|
|
108
|
+
useAttribute: true
|
|
109
|
+
},
|
|
110
|
+
startIndex: true,
|
|
111
|
+
reversed: true
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
image: {
|
|
115
|
+
insert: {
|
|
116
|
+
integrations: ['insertImageViaUrl']
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
table: {
|
|
120
|
+
contentToolbar: ['tableColumn', 'tableRow', 'mergeTableCells', 'tableProperties', 'tableCellProperties'],
|
|
121
|
+
tableProperties: {
|
|
122
|
+
borderColors: TEXT_COLOR_PALETTE,
|
|
123
|
+
backgroundColors: TEXT_COLOR_PALETTE
|
|
124
|
+
},
|
|
125
|
+
tableCellProperties: {
|
|
126
|
+
borderColors: TEXT_COLOR_PALETTE,
|
|
127
|
+
backgroundColors: TEXT_COLOR_PALETTE
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// Add stable data attributes to toolbar buttons for the styling (or testing) purposes
|
|
134
|
+
export var addButtonDataAttributes = function addButtonDataAttributes(editor) {
|
|
135
|
+
var applyAttributes = function applyAttributes() {
|
|
136
|
+
var toolbarElement = editor.ui.view.toolbar.element;
|
|
137
|
+
if (!toolbarElement) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Get buttons in the main toolbar
|
|
142
|
+
var toolbarChildren = Array.from(toolbarElement.querySelectorAll('.ck-toolbar__items > *'));
|
|
143
|
+
|
|
144
|
+
// Get buttons hidden in "more" dropdown
|
|
145
|
+
var moreDropdownButtons = Array.from(toolbarElement.querySelectorAll('.ck-dropdown__panel .ck-list .ck-button'));
|
|
146
|
+
var allToolbarElements = [].concat(toolbarChildren, moreDropdownButtons);
|
|
147
|
+
|
|
148
|
+
// Create mapping based on toolbar configuration order
|
|
149
|
+
var toolbarItems = editor.config.get('toolbar') || [];
|
|
150
|
+
var elementIndex = 0;
|
|
151
|
+
toolbarItems.forEach(function (itemName) {
|
|
152
|
+
var element = allToolbarElements[elementIndex];
|
|
153
|
+
if (itemName !== '|' && element && !element.classList.contains('ck-toolbar__separator')) {
|
|
154
|
+
// Use the toolbar item name as the stable identifier
|
|
155
|
+
element.setAttribute('data-cke-command', itemName);
|
|
156
|
+
}
|
|
157
|
+
elementIndex++;
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// Apply attributes initially
|
|
162
|
+
applyAttributes();
|
|
163
|
+
|
|
164
|
+
// Re-apply when dropdown menus are opened (buttons get created dynamically)
|
|
165
|
+
var toolbarElement = editor.ui.view.toolbar.element;
|
|
166
|
+
if (toolbarElement) {
|
|
167
|
+
var observer = new MutationObserver(function () {
|
|
168
|
+
applyAttributes();
|
|
169
|
+
});
|
|
170
|
+
observer.observe(toolbarElement, {
|
|
171
|
+
childList: true,
|
|
172
|
+
subtree: true
|
|
173
|
+
});
|
|
174
|
+
editor.on('destroy', function () {
|
|
175
|
+
observer.disconnect();
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","names":["Alignment","AutoLink","Bold","Clipboard","Essentials","FontBackgroundColor","FontColor","FontSize","GeneralHtmlSupport","Image","ImageInsert","ImageToolbar","Indent","IndentBlock","Italic","Link","List","ListProperties","Paragraph","Strikethrough","Table","TableCaption","TableCellProperties","TableColumnResize","TableProperties","TableToolbar","Underline","CK_EDITOR_LICENSE_KEY","CutPlugin","IndentPaddingToMarginPlugin","PasteAsTextPlugin","PastePlugin","TabSpacesPlugin","getEditorTranslation","getValidEditorLocale","TEXT_COLOR_PALETTE","color","getDefaultConfig","locale","arguments","length","undefined","licenseKey","language","translations","plugins","toolbar","fontSize","options","title","model","supportAllValues","fontColor","colors","fontBackgroundColor","indentBlock","offset","unit","htmlSupport","allow","name","styles","list","properties","useAttribute","startIndex","reversed","image","insert","integrations","table","contentToolbar","tableProperties","borderColors","backgroundColors","tableCellProperties","addButtonDataAttributes","editor","applyAttributes","toolbarElement","ui","view","element","toolbarChildren","Array","from","querySelectorAll","moreDropdownButtons","allToolbarElements","concat","toolbarItems","config","get","elementIndex","forEach","itemName","classList","contains","setAttribute","observer","MutationObserver","observe","childList","subtree","on","disconnect"],"sources":["../../../src/TextEditor/utils/config.ts"],"sourcesContent":["import type { ClassicEditor, EditorConfig } from 'ckeditor5'\nimport {\n Alignment,\n AutoLink,\n Bold,\n Clipboard,\n Essentials,\n FontBackgroundColor,\n FontColor,\n FontSize,\n GeneralHtmlSupport,\n Image,\n ImageInsert,\n ImageToolbar,\n Indent,\n IndentBlock,\n Italic,\n Link,\n List,\n ListProperties,\n Paragraph,\n Strikethrough,\n Table,\n TableCaption,\n TableCellProperties,\n TableColumnResize,\n TableProperties,\n TableToolbar,\n Underline,\n} from 'ckeditor5'\n\nimport { CK_EDITOR_LICENSE_KEY } from '../license_key'\nimport { CutPlugin } from '../plugins/CutPlugin'\nimport { IndentPaddingToMarginPlugin } from '../plugins/IndentPaddingToMarginPlugin'\nimport { PasteAsTextPlugin } from '../plugins/PasteAsTextPlugin'\nimport { PastePlugin } from '../plugins/PastePlugin'\nimport { TabSpacesPlugin } from '../plugins/TabSpacesPlugin'\nimport { getEditorTranslation, getValidEditorLocale } from './locale'\n\nconst TEXT_COLOR_PALETTE = [\n { color: '#BFEDD2' },\n { color: '#FBEEB8' },\n { color: '#F8CAC6' },\n { color: '#ECCAFA' },\n { color: '#C2E0F4' },\n { color: '#2DC26B' },\n { color: '#F1C40F' },\n { color: '#E03E2D' },\n { color: '#B96AD9' },\n { color: '#3598DB' },\n { color: '#169179' },\n { color: '#E67E23' },\n { color: '#BA372A' },\n { color: '#843FA1' },\n { color: '#236FA1' },\n { color: '#ECF0F1' },\n { color: '#CED4D9' },\n { color: '#95A5A6' },\n { color: '#7E8C8D' },\n { color: '#34495E' },\n { color: '#000000' },\n { color: '#FFFFFF' },\n]\n\nexport const getDefaultConfig = (locale: string = 'en'): EditorConfig => ({\n licenseKey: CK_EDITOR_LICENSE_KEY,\n language: getValidEditorLocale(locale),\n translations: [getEditorTranslation(locale)],\n plugins: [\n Alignment,\n AutoLink,\n Bold,\n Clipboard,\n Essentials,\n FontBackgroundColor,\n FontColor,\n FontSize,\n GeneralHtmlSupport,\n Indent,\n IndentBlock,\n Italic,\n Link,\n List,\n ListProperties,\n Paragraph,\n Strikethrough,\n Table,\n TableCaption,\n TableCellProperties,\n TableColumnResize,\n TableProperties,\n TableToolbar,\n Underline,\n Image,\n ImageInsert,\n ImageToolbar,\n CutPlugin,\n PastePlugin,\n PasteAsTextPlugin,\n IndentPaddingToMarginPlugin,\n TabSpacesPlugin,\n ],\n toolbar: [\n 'bold',\n 'italic',\n 'underline',\n 'strikethrough',\n '|',\n 'alignment:left',\n 'alignment:center',\n 'alignment:right',\n '|',\n 'bulletedList',\n 'numberedList',\n '|',\n 'outdent',\n 'indent',\n '|',\n 'cut',\n 'paste',\n 'pasteAsText',\n '|',\n 'fontSize',\n '|',\n 'fontColor',\n 'fontBackgroundColor',\n '|',\n 'undo',\n 'redo',\n ],\n fontSize: {\n options: [\n { title: '8pt', model: '8px' },\n { title: '10pt', model: '10px' },\n { title: '12pt', model: '12px' },\n { title: '14pt', model: '14px' },\n { title: '18pt', model: '18px' },\n { title: '24pt', model: '24px' },\n { title: '36pt', model: '36px' },\n ],\n supportAllValues: true,\n },\n fontColor: {\n colors: TEXT_COLOR_PALETTE,\n },\n fontBackgroundColor: {\n colors: TEXT_COLOR_PALETTE,\n },\n indentBlock: {\n offset: 40,\n unit: 'px',\n },\n htmlSupport: {\n allow: [\n {\n name: 'p',\n styles: {\n 'margin-left': true,\n },\n },\n ],\n },\n list: {\n properties: {\n styles: {\n useAttribute: true,\n },\n startIndex: true,\n reversed: true,\n },\n },\n image: {\n insert: {\n integrations: ['insertImageViaUrl'],\n },\n },\n table: {\n contentToolbar: [\n 'tableColumn',\n 'tableRow',\n 'mergeTableCells',\n 'tableProperties',\n 'tableCellProperties',\n ],\n tableProperties: {\n borderColors: TEXT_COLOR_PALETTE,\n backgroundColors: TEXT_COLOR_PALETTE,\n },\n tableCellProperties: {\n borderColors: TEXT_COLOR_PALETTE,\n backgroundColors: TEXT_COLOR_PALETTE,\n },\n },\n})\n\n// Add stable data attributes to toolbar buttons for the styling (or testing) purposes\nexport const addButtonDataAttributes = (editor: ClassicEditor) => {\n const applyAttributes = () => {\n const toolbarElement = editor.ui.view.toolbar.element\n if (!toolbarElement) {\n return\n }\n\n // Get buttons in the main toolbar\n const toolbarChildren = Array.from(\n toolbarElement.querySelectorAll('.ck-toolbar__items > *')\n )\n\n // Get buttons hidden in \"more\" dropdown\n const moreDropdownButtons = Array.from(\n toolbarElement.querySelectorAll('.ck-dropdown__panel .ck-list .ck-button')\n )\n\n const allToolbarElements = [...toolbarChildren, ...moreDropdownButtons]\n\n // Create mapping based on toolbar configuration order\n const toolbarItems = (editor.config.get('toolbar') || []) as string[]\n let elementIndex = 0\n\n toolbarItems.forEach((itemName) => {\n const element = allToolbarElements[elementIndex]\n if (\n itemName !== '|' &&\n element &&\n !element.classList.contains('ck-toolbar__separator')\n ) {\n // Use the toolbar item name as the stable identifier\n element.setAttribute('data-cke-command', itemName)\n }\n elementIndex++\n })\n }\n\n // Apply attributes initially\n applyAttributes()\n\n // Re-apply when dropdown menus are opened (buttons get created dynamically)\n const toolbarElement = editor.ui.view.toolbar.element\n if (toolbarElement) {\n const observer = new MutationObserver(() => {\n applyAttributes()\n })\n observer.observe(toolbarElement, {\n childList: true,\n subtree: true,\n })\n editor.on('destroy', () => {\n observer.disconnect()\n })\n }\n}\n"],"mappings":"AACA,SACEA,SAAS,EACTC,QAAQ,EACRC,IAAI,EACJC,SAAS,EACTC,UAAU,EACVC,mBAAmB,EACnBC,SAAS,EACTC,QAAQ,EACRC,kBAAkB,EAClBC,KAAK,EACLC,WAAW,EACXC,YAAY,EACZC,MAAM,EACNC,WAAW,EACXC,MAAM,EACNC,IAAI,EACJC,IAAI,EACJC,cAAc,EACdC,SAAS,EACT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B,SAAS,EAAE,IAAI;MACfC,OAAO,EAAE;IACX,CAAC,CAAC;IACF1B,MAAM,CAAC2B,EAAE,CAAC,SAAS,EAAE,YAAM;MACzBL,QAAQ,CAACM,UAAU,CAAC,CAAC;IACvB,CAAC,CAAC;EACJ;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["addButtonDataAttributes","getDefaultConfig","addPluginsFromStringArray"],"sources":["../../../src/TextEditor/utils/index.ts"],"sourcesContent":["export { addButtonDataAttributes, getDefaultConfig } from './config'\nexport { addPluginsFromStringArray } from './plugins'\n"],"mappings":"AAAA,SAASA,uBAAuB,EAAEC,gBAAgB,QAAQ,UAAU;AACpE,SAASC,yBAAyB,QAAQ,WAAW"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// @ts-expect-error: Translation files are not typed in the ckeditor5 package.
|
|
2
|
+
import de from 'ckeditor5/translations/de.js';
|
|
3
|
+
// @ts-expect-error: Translation files are not typed in the ckeditor5 package.
|
|
4
|
+
import en from 'ckeditor5/translations/en.js';
|
|
5
|
+
// @ts-expect-error: Translation files are not typed in the ckeditor5 package.
|
|
6
|
+
import es from 'ckeditor5/translations/es.js';
|
|
7
|
+
// @ts-expect-error: Translation files are not typed in the ckeditor5 package.
|
|
8
|
+
import fr from 'ckeditor5/translations/fr.js';
|
|
9
|
+
// @ts-expect-error: Translation files are not typed in the ckeditor5 package.
|
|
10
|
+
import ja from 'ckeditor5/translations/ja.js';
|
|
11
|
+
// @ts-expect-error: Translation files are not typed in the ckeditor5 package.
|
|
12
|
+
import pl from 'ckeditor5/translations/pl.js';
|
|
13
|
+
// @ts-expect-error: Translation files are not typed in the ckeditor5 package.
|
|
14
|
+
import pt from 'ckeditor5/translations/pt.js';
|
|
15
|
+
// @ts-expect-error: Translation files are not typed in the ckeditor5 package.
|
|
16
|
+
import th from 'ckeditor5/translations/th.js';
|
|
17
|
+
// @ts-expect-error: Translation files are not typed in the ckeditor5 package.
|
|
18
|
+
import zh from 'ckeditor5/translations/zh.js';
|
|
19
|
+
import { add } from '@ckeditor/ckeditor5-utils/src/translation-service';
|
|
20
|
+
var editorLocaleMap = {
|
|
21
|
+
en: 'en',
|
|
22
|
+
'en-CA': 'en',
|
|
23
|
+
'fr-CA': 'fr',
|
|
24
|
+
'fr-FR': 'fr',
|
|
25
|
+
es: 'es',
|
|
26
|
+
'es-ES': 'es',
|
|
27
|
+
'en-AE': 'en',
|
|
28
|
+
'en-AU': 'en',
|
|
29
|
+
'en-GB': 'en',
|
|
30
|
+
'en-SG': 'en',
|
|
31
|
+
'th-TH': 'th',
|
|
32
|
+
'ja-JP': 'ja',
|
|
33
|
+
'pt-BR': 'pt',
|
|
34
|
+
'is-IS': 'en',
|
|
35
|
+
'de-DE': 'de',
|
|
36
|
+
'zh-SG': 'zh',
|
|
37
|
+
'pl-PL': 'pl'
|
|
38
|
+
};
|
|
39
|
+
var editorTranslations = {
|
|
40
|
+
en: en,
|
|
41
|
+
fr: fr,
|
|
42
|
+
es: es,
|
|
43
|
+
de: de,
|
|
44
|
+
ja: ja,
|
|
45
|
+
pl: pl,
|
|
46
|
+
pt: pt,
|
|
47
|
+
th: th,
|
|
48
|
+
zh: zh
|
|
49
|
+
};
|
|
50
|
+
add('en', {
|
|
51
|
+
Cut: 'Cut',
|
|
52
|
+
Paste: 'Paste',
|
|
53
|
+
PasteAsText: 'Paste as Text'
|
|
54
|
+
});
|
|
55
|
+
add('fr', {
|
|
56
|
+
Cut: 'Couper',
|
|
57
|
+
Paste: 'Coller',
|
|
58
|
+
PasteAsText: 'Coller comme texte'
|
|
59
|
+
});
|
|
60
|
+
add('ja', {
|
|
61
|
+
Cut: 'カット',
|
|
62
|
+
Paste: '貼り付け',
|
|
63
|
+
PasteAsText: 'テキストとして貼り付け'
|
|
64
|
+
});
|
|
65
|
+
add('es', {
|
|
66
|
+
Cut: 'Cortar',
|
|
67
|
+
Paste: 'Pegar',
|
|
68
|
+
PasteAsText: 'Pegar como texto'
|
|
69
|
+
});
|
|
70
|
+
add('de', {
|
|
71
|
+
Cut: 'Ausschneiden',
|
|
72
|
+
Paste: 'Einfügen',
|
|
73
|
+
PasteAsText: 'Als Text einfügen'
|
|
74
|
+
});
|
|
75
|
+
add('pt', {
|
|
76
|
+
Cut: 'Recortar',
|
|
77
|
+
Paste: 'Colar',
|
|
78
|
+
PasteAsText: 'Colar como texto'
|
|
79
|
+
});
|
|
80
|
+
add('zh', {
|
|
81
|
+
Cut: '剪切',
|
|
82
|
+
Paste: '粘贴',
|
|
83
|
+
PasteAsText: '以文本形式粘贴'
|
|
84
|
+
});
|
|
85
|
+
add('th', {
|
|
86
|
+
Cut: 'ตัด',
|
|
87
|
+
Paste: 'วาง',
|
|
88
|
+
PasteAsText: 'วางในรูปแบบข้อความ'
|
|
89
|
+
});
|
|
90
|
+
add('pl', {
|
|
91
|
+
Cut: 'Wytnij',
|
|
92
|
+
Paste: 'Wklej',
|
|
93
|
+
PasteAsText: 'Wklej jako tekst'
|
|
94
|
+
});
|
|
95
|
+
export var getValidEditorLocale = function getValidEditorLocale(locale) {
|
|
96
|
+
return editorLocaleMap[locale] || 'en';
|
|
97
|
+
};
|
|
98
|
+
export var getEditorTranslation = function getEditorTranslation(locale) {
|
|
99
|
+
var editorLocale = getValidEditorLocale(locale);
|
|
100
|
+
return editorTranslations[editorLocale] || en;
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=locale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale.js","names":["de","en","es","fr","ja","pl","pt","th","zh","add","editorLocaleMap","editorTranslations","Cut","Paste","PasteAsText","getValidEditorLocale","locale","getEditorTranslation","editorLocale"],"sources":["../../../src/TextEditor/utils/locale.ts"],"sourcesContent":["import type { Translations } from 'ckeditor5'\n// @ts-expect-error: Translation files are not typed in the ckeditor5 package.\nimport de from 'ckeditor5/translations/de.js'\n// @ts-expect-error: Translation files are not typed in the ckeditor5 package.\nimport en from 'ckeditor5/translations/en.js'\n// @ts-expect-error: Translation files are not typed in the ckeditor5 package.\nimport es from 'ckeditor5/translations/es.js'\n// @ts-expect-error: Translation files are not typed in the ckeditor5 package.\nimport fr from 'ckeditor5/translations/fr.js'\n// @ts-expect-error: Translation files are not typed in the ckeditor5 package.\nimport ja from 'ckeditor5/translations/ja.js'\n// @ts-expect-error: Translation files are not typed in the ckeditor5 package.\nimport pl from 'ckeditor5/translations/pl.js'\n// @ts-expect-error: Translation files are not typed in the ckeditor5 package.\nimport pt from 'ckeditor5/translations/pt.js'\n// @ts-expect-error: Translation files are not typed in the ckeditor5 package.\nimport th from 'ckeditor5/translations/th.js'\n// @ts-expect-error: Translation files are not typed in the ckeditor5 package.\nimport zh from 'ckeditor5/translations/zh.js'\n\nimport { add } from '@ckeditor/ckeditor5-utils/src/translation-service'\n\nconst editorLocaleMap: Record<string, string> = {\n en: 'en',\n 'en-CA': 'en',\n 'fr-CA': 'fr',\n 'fr-FR': 'fr',\n es: 'es',\n 'es-ES': 'es',\n 'en-AE': 'en',\n 'en-AU': 'en',\n 'en-GB': 'en',\n 'en-SG': 'en',\n 'th-TH': 'th',\n 'ja-JP': 'ja',\n 'pt-BR': 'pt',\n 'is-IS': 'en',\n 'de-DE': 'de',\n 'zh-SG': 'zh',\n 'pl-PL': 'pl',\n}\n\nconst editorTranslations: Record<string, Translations> = {\n en,\n fr,\n es,\n de,\n ja,\n pl,\n pt,\n th,\n zh,\n}\n\nadd('en', {\n Cut: 'Cut',\n Paste: 'Paste',\n PasteAsText: 'Paste as Text',\n})\nadd('fr', {\n Cut: 'Couper',\n Paste: 'Coller',\n PasteAsText: 'Coller comme texte',\n})\nadd('ja', {\n Cut: 'カット',\n Paste: '貼り付け',\n PasteAsText: 'テキストとして貼り付け',\n})\nadd('es', {\n Cut: 'Cortar',\n Paste: 'Pegar',\n PasteAsText: 'Pegar como texto',\n})\nadd('de', {\n Cut: 'Ausschneiden',\n Paste: 'Einfügen',\n PasteAsText: 'Als Text einfügen',\n})\nadd('pt', {\n Cut: 'Recortar',\n Paste: 'Colar',\n PasteAsText: 'Colar como texto',\n})\nadd('zh', {\n Cut: '剪切',\n Paste: '粘贴',\n PasteAsText: '以文本形式粘贴',\n})\nadd('th', {\n Cut: 'ตัด',\n Paste: 'วาง',\n PasteAsText: 'วางในรูปแบบข้อความ',\n})\nadd('pl', {\n Cut: 'Wytnij',\n Paste: 'Wklej',\n PasteAsText: 'Wklej jako tekst',\n})\n\nexport const getValidEditorLocale = (locale: string) => {\n return editorLocaleMap[locale] || 'en'\n}\n\nexport const getEditorTranslation = (locale: string) => {\n const editorLocale = getValidEditorLocale(locale)\n return editorTranslations[editorLocale] || en\n}\n"],"mappings":"AACA;AACA,OAAOA,EAAE,MAAM,8BAA8B;AAC7C;AACA,OAAOC,EAAE,MAAM,8BAA8B;AAC7C;AACA,OAAOC,EAAE,MAAM,8BAA8B;AAC7C;AACA,OAAOC,EAAE,MAAM,8BAA8B;AAC7C;AACA,OAAOC,EAAE,MAAM,8BAA8B;AAC7C;AACA,OAAOC,EAAE,MAAM,8BAA8B;AAC7C;AACA,OAAOC,EAAE,MAAM,8BAA8B;AAC7C;AACA,OAAOC,EAAE,MAAM,8BAA8B;AAC7C;AACA,OAAOC,EAAE,MAAM,8BAA8B;AAE7C,SAASC,GAAG,QAAQ,mDAAmD;AAEvE,IAAMC,eAAuC,GAAG;EAC9CT,EAAE,EAAE,IAAI;EACR,OAAO,EAAE,IAAI;EACb,OAAO,EAAE,IAAI;EACb,OAAO,EAAE,IAAI;EACbC,EAAE,EAAE,IAAI;EACR,OAAO,EAAE,IAAI;EACb,OAAO,EAAE,IAAI;EACb,OAAO,EAAE,IAAI;EACb,OAAO,EAAE,IAAI;EACb,OAAO,EAAE,IAAI;EACb,OAAO,EAAE,IAAI;EACb,OAAO,EAAE,IAAI;EACb,OAAO,EAAE,IAAI;EACb,OAAO,EAAE,IAAI;EACb,OAAO,EAAE,IAAI;EACb,OAAO,EAAE,IAAI;EACb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