@aquera/nile-elements 0.1.67-beta-1.5 → 0.1.67-beta-1.7
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/demo/index.html +24 -11
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +130 -58
- package/dist/nile-avatar/nile-avatar.test.cjs.js +1 -1
- package/dist/nile-avatar/nile-avatar.test.cjs.js.map +1 -1
- package/dist/nile-avatar/nile-avatar.test.esm.js +1 -1
- package/dist/nile-badge/index.cjs.js +1 -1
- package/dist/nile-badge/index.esm.js +1 -1
- package/dist/nile-badge/nile-badge.cjs.js +1 -1
- package/dist/nile-badge/nile-badge.cjs.js.map +1 -1
- package/dist/nile-badge/nile-badge.esm.js +1 -1
- package/dist/nile-badge/nile-badge.test.cjs.js +1 -1
- package/dist/nile-badge/nile-badge.test.cjs.js.map +1 -1
- package/dist/nile-badge/nile-badge.test.esm.js +1 -1
- package/dist/nile-button/index.cjs.js +1 -1
- package/dist/nile-button/index.esm.js +1 -1
- package/dist/nile-button/nile-button.cjs.js +1 -1
- package/dist/nile-button/nile-button.cjs.js.map +1 -1
- package/dist/nile-button/nile-button.esm.js +1 -1
- package/dist/nile-button/nile-button.test.cjs.js +1 -1
- package/dist/nile-button/nile-button.test.cjs.js.map +1 -1
- package/dist/nile-button/nile-button.test.esm.js +1 -1
- package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.test.cjs.js.map +1 -1
- package/dist/nile-calendar/nile-calendar.test.esm.js +1 -1
- package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
- package/dist/nile-chip/nile-chip.test.cjs.js.map +1 -1
- package/dist/nile-chip/nile-chip.test.esm.js +1 -1
- package/dist/nile-dialog/index.cjs.js +1 -1
- package/dist/nile-dialog/index.esm.js +1 -1
- package/dist/nile-dialog/nile-dialog.cjs.js +1 -1
- package/dist/nile-dialog/nile-dialog.cjs.js.map +1 -1
- package/dist/nile-dialog/nile-dialog.esm.js +2 -2
- package/dist/nile-dialog/nile-dialog.test.cjs.js +1 -1
- package/dist/nile-dialog/nile-dialog.test.cjs.js.map +1 -1
- package/dist/nile-dialog/nile-dialog.test.esm.js +1 -1
- package/dist/nile-drawer/index.cjs.js +1 -1
- package/dist/nile-drawer/index.esm.js +1 -1
- package/dist/nile-drawer/nile-drawer.cjs.js +1 -1
- package/dist/nile-drawer/nile-drawer.cjs.js.map +1 -1
- package/dist/nile-drawer/nile-drawer.esm.js +1 -1
- package/dist/nile-drawer/nile-drawer.test.cjs.js +1 -1
- package/dist/nile-drawer/nile-drawer.test.cjs.js.map +1 -1
- package/dist/nile-drawer/nile-drawer.test.esm.js +1 -1
- package/dist/nile-icon/icons/svg/format_clear.cjs.js +2 -0
- package/dist/nile-icon/icons/svg/format_clear.cjs.js.map +1 -0
- package/dist/nile-icon/icons/svg/format_clear.esm.js +1 -0
- package/dist/nile-icon/icons/svg/format_list_bulleted.cjs.js +2 -0
- package/dist/nile-icon/icons/svg/format_list_bulleted.cjs.js.map +1 -0
- package/dist/nile-icon/icons/svg/format_list_bulleted.esm.js +1 -0
- package/dist/nile-icon/icons/svg/format_list_numbered.cjs.js +2 -0
- package/dist/nile-icon/icons/svg/format_list_numbered.cjs.js.map +1 -0
- package/dist/nile-icon/icons/svg/format_list_numbered.esm.js +1 -0
- package/dist/nile-icon/icons/svg/index.cjs.js +1 -1
- package/dist/nile-icon/icons/svg/index.esm.js +1 -1
- package/dist/nile-icon/index.cjs.js +1 -1
- package/dist/nile-icon/index.cjs.js.map +1 -1
- package/dist/nile-icon/index.esm.js +2 -2
- package/dist/nile-icon/nile-icon.test.cjs.js +1 -1
- package/dist/nile-icon/nile-icon.test.cjs.js.map +1 -1
- package/dist/nile-icon/nile-icon.test.esm.js +1 -1
- package/dist/nile-icon-button/index.cjs.js +1 -1
- package/dist/nile-icon-button/index.esm.js +1 -1
- package/dist/nile-icon-button/nile-icon-button.cjs.js +1 -1
- package/dist/nile-icon-button/nile-icon-button.cjs.js.map +1 -1
- package/dist/nile-icon-button/nile-icon-button.esm.js +1 -1
- package/dist/nile-input/index.cjs.js +1 -1
- package/dist/nile-input/index.esm.js +1 -1
- package/dist/nile-input/nile-input.cjs.js +1 -1
- package/dist/nile-input/nile-input.cjs.js.map +1 -1
- package/dist/nile-input/nile-input.esm.js +1 -1
- package/dist/nile-input/nile-input.test.cjs.js +1 -1
- package/dist/nile-input/nile-input.test.cjs.js.map +1 -1
- package/dist/nile-input/nile-input.test.esm.js +1 -1
- package/dist/nile-menu-item/index.cjs.js +1 -1
- package/dist/nile-menu-item/index.esm.js +1 -1
- package/dist/nile-menu-item/nile-menu-item.cjs.js +1 -1
- package/dist/nile-menu-item/nile-menu-item.cjs.js.map +1 -1
- package/dist/nile-menu-item/nile-menu-item.esm.js +1 -1
- package/dist/nile-option/index.cjs.js +1 -1
- package/dist/nile-option/index.esm.js +1 -1
- package/dist/nile-option/nile-option.cjs.js +1 -1
- package/dist/nile-option/nile-option.cjs.js.map +1 -1
- package/dist/nile-option/nile-option.esm.js +1 -1
- package/dist/nile-rich-text-editor/index.cjs.js +1 -1
- package/dist/nile-rich-text-editor/index.esm.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.esm.js +14 -13
- package/dist/nile-rich-text-editor/nile-rich-text-editor.esm.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-color.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-color.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rte-color.esm.js +54 -1
- package/dist/nile-rich-text-editor/nile-rte-link.cjs.js +2 -0
- package/dist/nile-rich-text-editor/nile-rte-link.cjs.js.map +1 -0
- package/dist/nile-rich-text-editor/nile-rte-link.esm.js +19 -0
- package/dist/nile-rich-text-editor/nile-rte-select.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-select.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rte-select.esm.js +39 -39
- package/dist/nile-rich-text-editor/utils.cjs.js +1 -1
- package/dist/nile-rich-text-editor/utils.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/utils.esm.js +1 -1
- package/dist/nile-select/index.cjs.js +1 -1
- package/dist/nile-select/index.esm.js +1 -1
- package/dist/nile-select/nile-select.cjs.js +1 -1
- package/dist/nile-select/nile-select.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.esm.js +1 -1
- package/dist/nile-select/nile-select.test.cjs.js +1 -1
- package/dist/nile-select/nile-select.test.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.test.esm.js +1 -1
- package/dist/nile-tab/index.cjs.js +1 -1
- package/dist/nile-tab/index.esm.js +1 -1
- package/dist/nile-tab/nile-tab.cjs.js +1 -1
- package/dist/nile-tab/nile-tab.cjs.js.map +1 -1
- package/dist/nile-tab/nile-tab.esm.js +1 -1
- package/dist/nile-tab-group/index.cjs.js +1 -1
- package/dist/nile-tab-group/index.esm.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.cjs.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.cjs.js.map +1 -1
- package/dist/nile-tab-group/nile-tab-group.esm.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.test.cjs.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.test.cjs.js.map +1 -1
- package/dist/nile-tab-group/nile-tab-group.test.esm.js +1 -1
- package/dist/nile-tag/index.cjs.js +1 -1
- package/dist/nile-tag/index.esm.js +1 -1
- package/dist/nile-tag/nile-tag.cjs.js +1 -1
- package/dist/nile-tag/nile-tag.cjs.js.map +1 -1
- package/dist/nile-tag/nile-tag.esm.js +1 -1
- package/dist/nile-toast/index.cjs.js +1 -1
- package/dist/nile-toast/index.esm.js +1 -1
- package/dist/nile-toast/nile-toast.cjs.js +1 -1
- package/dist/nile-toast/nile-toast.cjs.js.map +1 -1
- package/dist/nile-toast/nile-toast.esm.js +1 -1
- package/dist/nile-tree/index.cjs.js +1 -1
- package/dist/nile-tree/index.esm.js +1 -1
- package/dist/nile-tree/nile-tree.cjs.js +1 -1
- package/dist/nile-tree/nile-tree.cjs.js.map +1 -1
- package/dist/nile-tree/nile-tree.esm.js +1 -1
- package/dist/nile-tree-item/index.cjs.js +1 -1
- package/dist/nile-tree-item/index.esm.js +1 -1
- package/dist/nile-tree-item/nile-tree-item.cjs.js +1 -1
- package/dist/nile-tree-item/nile-tree-item.cjs.js.map +1 -1
- package/dist/nile-tree-item/nile-tree-item.esm.js +1 -1
- package/dist/nile-virtual-select/index.cjs.js +1 -1
- package/dist/nile-virtual-select/index.esm.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.esm.js +1 -1
- package/dist/src/nile-icon/icons/svg/format_clear.d.ts +5 -0
- package/dist/src/nile-icon/icons/svg/format_clear.js +5 -0
- package/dist/src/nile-icon/icons/svg/format_clear.js.map +1 -0
- package/dist/src/nile-icon/icons/svg/format_list_bulleted.d.ts +5 -0
- package/dist/src/nile-icon/icons/svg/format_list_bulleted.js +5 -0
- package/dist/src/nile-icon/icons/svg/format_list_bulleted.js.map +1 -0
- package/dist/src/nile-icon/icons/svg/format_list_numbered.d.ts +5 -0
- package/dist/src/nile-icon/icons/svg/format_list_numbered.js +5 -0
- package/dist/src/nile-icon/icons/svg/format_list_numbered.js.map +1 -0
- package/dist/src/nile-icon/icons/svg/index.d.ts +3 -0
- package/dist/src/nile-icon/icons/svg/index.js +3 -0
- package/dist/src/nile-icon/icons/svg/index.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js +14 -13
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.d.ts +1 -0
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js +38 -90
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-color.d.ts +11 -3
- package/dist/src/nile-rich-text-editor/nile-rte-color.js +171 -6
- package/dist/src/nile-rich-text-editor/nile-rte-color.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-link.d.ts +19 -0
- package/dist/src/nile-rich-text-editor/nile-rte-link.js +172 -0
- package/dist/src/nile-rich-text-editor/nile-rte-link.js.map +1 -0
- package/dist/src/nile-rich-text-editor/nile-rte-select.js +62 -57
- package/dist/src/nile-rich-text-editor/nile-rte-select.js.map +1 -1
- package/dist/src/nile-rich-text-editor/rte-utils/content.d.ts +2 -0
- package/dist/src/nile-rich-text-editor/rte-utils/content.js +25 -0
- package/dist/src/nile-rich-text-editor/rte-utils/content.js.map +1 -0
- package/dist/src/nile-rich-text-editor/rte-utils/css.d.ts +1 -0
- package/dist/src/nile-rich-text-editor/rte-utils/css.js +9 -0
- package/dist/src/nile-rich-text-editor/rte-utils/css.js.map +1 -0
- package/dist/src/nile-rich-text-editor/rte-utils/dom.d.ts +2 -0
- package/dist/src/nile-rich-text-editor/rte-utils/dom.js +48 -0
- package/dist/src/nile-rich-text-editor/rte-utils/dom.js.map +1 -0
- package/dist/src/nile-rich-text-editor/rte-utils/formatting.d.ts +2 -0
- package/dist/src/nile-rich-text-editor/rte-utils/formatting.js +69 -0
- package/dist/src/nile-rich-text-editor/rte-utils/formatting.js.map +1 -0
- package/dist/src/nile-rich-text-editor/rte-utils/keys.d.ts +2 -0
- package/dist/src/nile-rich-text-editor/rte-utils/keys.js +38 -0
- package/dist/src/nile-rich-text-editor/rte-utils/keys.js.map +1 -0
- package/dist/src/nile-rich-text-editor/rte-utils/lists.d.ts +2 -0
- package/dist/src/nile-rich-text-editor/rte-utils/lists.js +28 -0
- package/dist/src/nile-rich-text-editor/rte-utils/lists.js.map +1 -0
- package/dist/src/nile-rich-text-editor/rte-utils/selection.d.ts +17 -0
- package/dist/src/nile-rich-text-editor/rte-utils/selection.js +39 -0
- package/dist/src/nile-rich-text-editor/rte-utils/selection.js.map +1 -0
- package/dist/src/nile-rich-text-editor/rte-utils/toolbar.d.ts +28 -0
- package/dist/src/nile-rich-text-editor/rte-utils/toolbar.js +161 -0
- package/dist/src/nile-rich-text-editor/rte-utils/toolbar.js.map +1 -0
- package/dist/src/nile-rich-text-editor/rte-utils/toolbarState.d.ts +13 -0
- package/dist/src/nile-rich-text-editor/rte-utils/toolbarState.js +119 -0
- package/dist/src/nile-rich-text-editor/rte-utils/toolbarState.js.map +1 -0
- package/dist/src/nile-rich-text-editor/rte-utils/vars.d.ts +1 -0
- package/dist/src/nile-rich-text-editor/rte-utils/vars.js +14 -0
- package/dist/src/nile-rich-text-editor/rte-utils/vars.js.map +1 -0
- package/dist/src/nile-rich-text-editor/sanatize.d.ts +1 -0
- package/dist/src/nile-rich-text-editor/sanatize.js +40 -0
- package/dist/src/nile-rich-text-editor/sanatize.js.map +1 -0
- package/dist/src/nile-rich-text-editor/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-icon/icons/svg/format_clear.ts +5 -0
- package/src/nile-icon/icons/svg/format_list_bulleted.ts +5 -0
- package/src/nile-icon/icons/svg/format_list_numbered.ts +5 -0
- package/src/nile-icon/icons/svg/index.ts +3 -0
- package/src/nile-rich-text-editor/nile-rich-text-editor.css.ts +14 -13
- package/src/nile-rich-text-editor/nile-rich-text-editor.ts +56 -90
- package/src/nile-rich-text-editor/nile-rte-color.ts +182 -6
- package/src/nile-rich-text-editor/nile-rte-link.ts +161 -0
- package/src/nile-rich-text-editor/nile-rte-select.ts +178 -173
- package/src/nile-rich-text-editor/utils.ts +342 -341
- package/vscode-html-custom-data.json +33 -3
@@ -1,2 +1,2 @@
|
|
1
|
-
System.register(["lit"],function(_export,_context){"use strict";var e,_templateObject,r;function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}return{setters:[function(_lit){e=_lit.css;}],execute:function execute(){_export("s",r=e(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n
|
1
|
+
System.register(["lit"],function(_export,_context){"use strict";var e,_templateObject,r;function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}return{setters:[function(_lit){e=_lit.css;}],execute:function execute(){_export("s",r=e(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n \n\n nile-rich-text-editor { position: relative; display: block; font-family: inherit; }\n\n \nnile-rte-toolbar-item > nile-button::part(base) {\n \n width:32px; height:32px; padding:0px 6px;\n border: none;\n}\n \n \n\n\n .toolbar, nile-rte-toolbar {\n display:flex; align-items:center; gap:6px; padding:8px; \n border:1px solid #e5e7eb; border-bottom:none; border-radius:8px 8px 0 0; background:#fff;\n }\n\n nile-rte-toolbar-item > button, .toolbar button, nile-rte-toolbar button {\n border:1px solid #e5e7eb; background:#fff; border-radius:6px;\n cursor:pointer;\n }\n\n \n /* Ensure clicks hit the button (not nested icon internals) */\n nile-rte-toolbar-item > button nile-icon { pointer-events:none; }\n\n nile-rte-toolbar-item > button.active { border-color:#2563eb; background:#eff6ff; }\n nile-rte-select select { height:32px; border:1px solid #e5e7eb; border-radius:6px; background:#fff; }\n nile-rte-color input[type=\"color\"] { height:32px; width:36px; border:1px solid #e5e7eb; padding:0; border-radius:6px; background:#fff; }\n nile-rte-divider { width:1px; height:20px; background:#e5e7eb; display:inline-block; margin:0 4px; }\n\n .editor p { margin:1em 0; }\n .editor h1, .preview h1 { font-size:2em, all: revert; display: block;\nfont-size: 2em;\nmargin-top: 0.67em;\nmargin-bottom: 0.67em;\nmargin-left: 0;\nmargin-right: 0;\nfont-weight: bold; }\n .editor h2, .preview h2 { all: revert;\tdisplay: block;\nfont-size: 1.5em;\nmargin-top: 0.83em;\nmargin-bottom: 0.83em;\nmargin-left: 0;\nmargin-right: 0;\nfont-weight: bold;}\n .editor h3 { font-size:1.17em }\n .editor h4 { font-size:1em }\n .editor h5 { font-size:0.83em }\n .editor h6 { font-size:0.67em }\n\n .editor { min-height:160px; padding:12px; border:1px solid #e5e7eb; border-radius:0 0 8px 8px; background:#fff; outline:none; white-space: pre-wrap;\n tab-size: 4; \n -moz-tab-size: 4; }\n nile-rte-preview { display:block; margin-top:10px; padding:10px; border:1px dashed #cbd5e1; border-radius:8px; background:#fafafa; }\n\n .rte-color-trigger {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n /* border: 1px solid var(--nile-color-border, #d9d9d9); */\n border-radius: 6px;\n background: #fff;\n cursor: pointer;\n border:none;\n \n\n}\nnile-button.rte-color-trigger::part(base){\n width:32px; height:32px; padding:0px 6px;\n}\n.rte-color-trigger .glyph-stack {\n display: grid; /* stack vertically */\n grid-auto-rows: max-content; \n align-items: center;\n justify-items: center;\n line-height: 1;\n}\n\n.rte-color-trigger .glyph {\n font-size: 14px;\n line-height: 1;\n margin-bottom: 2px; \n}\n\n.rte-color-trigger .underline {\n width: 18px;\n height: 3px;\n border-radius: 2px;\n background: currentColor; \n}\n\n \n.rte-color-trigger .swatch-box {\n width: 18px;\n height: 16px;\n border-radius: 4px;\n border: 1px solid rgba(0,0,0,0.35);\n background: currentColor; /* overridden via JS */\n}\n\n"]))));}};});
|
2
2
|
//# sourceMappingURL=nile-rich-text-editor.css.cjs.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-rich-text-editor.css.cjs.js","sources":["../../../src/nile-rich-text-editor/nile-rich-text-editor.css.ts"],"sourcesContent":["// rte-styles.ts\nimport { css } from 'lit';\n\nexport const styles = css`\n
|
1
|
+
{"version":3,"file":"nile-rich-text-editor.css.cjs.js","sources":["../../../src/nile-rich-text-editor/nile-rich-text-editor.css.ts"],"sourcesContent":["// rte-styles.ts\nimport { css } from 'lit';\n\nexport const styles = css`\n \n\n nile-rich-text-editor { position: relative; display: block; font-family: inherit; }\n\n \nnile-rte-toolbar-item > nile-button::part(base) {\n \n width:32px; height:32px; padding:0px 6px;\n border: none;\n}\n \n \n\n\n .toolbar, nile-rte-toolbar {\n display:flex; align-items:center; gap:6px; padding:8px; \n border:1px solid #e5e7eb; border-bottom:none; border-radius:8px 8px 0 0; background:#fff;\n }\n\n nile-rte-toolbar-item > button, .toolbar button, nile-rte-toolbar button {\n border:1px solid #e5e7eb; background:#fff; border-radius:6px;\n cursor:pointer;\n }\n\n \n /* Ensure clicks hit the button (not nested icon internals) */\n nile-rte-toolbar-item > button nile-icon { pointer-events:none; }\n\n nile-rte-toolbar-item > button.active { border-color:#2563eb; background:#eff6ff; }\n nile-rte-select select { height:32px; border:1px solid #e5e7eb; border-radius:6px; background:#fff; }\n nile-rte-color input[type=\"color\"] { height:32px; width:36px; border:1px solid #e5e7eb; padding:0; border-radius:6px; background:#fff; }\n nile-rte-divider { width:1px; height:20px; background:#e5e7eb; display:inline-block; margin:0 4px; }\n\n .editor p { margin:1em 0; }\n .editor h1, .preview h1 { font-size:2em, all: revert; display: block;\nfont-size: 2em;\nmargin-top: 0.67em;\nmargin-bottom: 0.67em;\nmargin-left: 0;\nmargin-right: 0;\nfont-weight: bold; }\n .editor h2, .preview h2 { all: revert;\tdisplay: block;\nfont-size: 1.5em;\nmargin-top: 0.83em;\nmargin-bottom: 0.83em;\nmargin-left: 0;\nmargin-right: 0;\nfont-weight: bold;}\n .editor h3 { font-size:1.17em }\n .editor h4 { font-size:1em }\n .editor h5 { font-size:0.83em }\n .editor h6 { font-size:0.67em }\n\n .editor { min-height:160px; padding:12px; border:1px solid #e5e7eb; border-radius:0 0 8px 8px; background:#fff; outline:none; white-space: pre-wrap;\n tab-size: 4; \n -moz-tab-size: 4; }\n nile-rte-preview { display:block; margin-top:10px; padding:10px; border:1px dashed #cbd5e1; border-radius:8px; background:#fafafa; }\n\n .rte-color-trigger {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n /* border: 1px solid var(--nile-color-border, #d9d9d9); */\n border-radius: 6px;\n background: #fff;\n cursor: pointer;\n border:none;\n \n\n}\nnile-button.rte-color-trigger::part(base){\n width:32px; height:32px; padding:0px 6px;\n}\n.rte-color-trigger .glyph-stack {\n display: grid; /* stack vertically */\n grid-auto-rows: max-content; \n align-items: center;\n justify-items: center;\n line-height: 1;\n}\n\n.rte-color-trigger .glyph {\n font-size: 14px;\n line-height: 1;\n margin-bottom: 2px; \n}\n\n.rte-color-trigger .underline {\n width: 18px;\n height: 3px;\n border-radius: 2px;\n background: currentColor; \n}\n\n \n.rte-color-trigger .swatch-box {\n width: 18px;\n height: 16px;\n border-radius: 4px;\n border: 1px solid rgba(0,0,0,0.35);\n background: currentColor; /* overridden via JS */\n}\n\n`;\n\nexport default [styles];"],"names":["styles","css","_templateObject","_taggedTemplateLiteral"],"mappings":"oTAGaA,CAAAA,CAASC,CAAG,CAAAC,eAAA,GAAAA,eAAA,CAAAC,sBAAA"}
|
@@ -1,7 +1,5 @@
|
|
1
1
|
import{css as e}from"lit";const r=e`
|
2
|
-
|
3
|
-
all: revert;
|
4
|
-
}
|
2
|
+
|
5
3
|
|
6
4
|
nile-rich-text-editor { position: relative; display: block; font-family: inherit; }
|
7
5
|
|
@@ -16,7 +14,7 @@ nile-rte-toolbar-item > nile-button::part(base) {
|
|
16
14
|
|
17
15
|
|
18
16
|
.toolbar, nile-rte-toolbar {
|
19
|
-
display:flex; align-items:center; gap:
|
17
|
+
display:flex; align-items:center; gap:6px; padding:8px;
|
20
18
|
border:1px solid #e5e7eb; border-bottom:none; border-radius:8px 8px 0 0; background:#fff;
|
21
19
|
}
|
22
20
|
|
@@ -35,14 +33,14 @@ nile-rte-toolbar-item > nile-button::part(base) {
|
|
35
33
|
nile-rte-divider { width:1px; height:20px; background:#e5e7eb; display:inline-block; margin:0 4px; }
|
36
34
|
|
37
35
|
.editor p { margin:1em 0; }
|
38
|
-
.editor h1 { font-size:2em, all: revert; display: block;
|
36
|
+
.editor h1, .preview h1 { font-size:2em, all: revert; display: block;
|
39
37
|
font-size: 2em;
|
40
38
|
margin-top: 0.67em;
|
41
39
|
margin-bottom: 0.67em;
|
42
40
|
margin-left: 0;
|
43
41
|
margin-right: 0;
|
44
42
|
font-weight: bold; }
|
45
|
-
.editor h2 { all: revert; display: block;
|
43
|
+
.editor h2, .preview h2 { all: revert; display: block;
|
46
44
|
font-size: 1.5em;
|
47
45
|
margin-top: 0.83em;
|
48
46
|
margin-bottom: 0.83em;
|
@@ -63,14 +61,17 @@ font-weight: bold;}
|
|
63
61
|
display: inline-flex;
|
64
62
|
align-items: center;
|
65
63
|
justify-content: center;
|
66
|
-
|
67
|
-
padding: 0 8px;
|
68
|
-
border: 1px solid var(--nile-color-border, #d9d9d9);
|
64
|
+
/* border: 1px solid var(--nile-color-border, #d9d9d9); */
|
69
65
|
border-radius: 6px;
|
70
66
|
background: #fff;
|
71
67
|
cursor: pointer;
|
72
|
-
|
68
|
+
border:none;
|
69
|
+
|
73
70
|
|
71
|
+
}
|
72
|
+
nile-button.rte-color-trigger::part(base){
|
73
|
+
width:32px; height:32px; padding:0px 6px;
|
74
|
+
}
|
74
75
|
.rte-color-trigger .glyph-stack {
|
75
76
|
display: grid; /* stack vertically */
|
76
77
|
grid-auto-rows: max-content;
|
@@ -82,17 +83,17 @@ font-weight: bold;}
|
|
82
83
|
.rte-color-trigger .glyph {
|
83
84
|
font-size: 14px;
|
84
85
|
line-height: 1;
|
85
|
-
margin-bottom: 2px;
|
86
|
+
margin-bottom: 2px;
|
86
87
|
}
|
87
88
|
|
88
89
|
.rte-color-trigger .underline {
|
89
90
|
width: 18px;
|
90
91
|
height: 3px;
|
91
92
|
border-radius: 2px;
|
92
|
-
background: currentColor;
|
93
|
+
background: currentColor;
|
93
94
|
}
|
94
95
|
|
95
|
-
|
96
|
+
|
96
97
|
.rte-color-trigger .swatch-box {
|
97
98
|
width: 18px;
|
98
99
|
height: 16px;
|
@@ -1 +1 @@
|
|
1
|
-
import{__decorate as t}from"tslib";import{LitElement as i}from"lit";import{property as s,state as e,customElement as n}from"lit/decorators.js";import"./nile-rte-toolbar.esm.js";import"./nile-rte-toolbar-item.esm.js";import"./nile-rte-select.esm.js";import"./nile-rte-color.esm.js";import"./nile-rte-divider.esm.js";import"./nile-rte-preview.esm.js";import"./nile-rte-mentions.esm.js";import{s as o,a as r,b as h,c as l,d as c,i as a,t as u,n as d,e as f,r as m}from"./utils.esm.js";import{s as p}from"./nile-rich-text-editor.css.esm.js";const b={bold:"format_bold",italic:"format_italic",underline:"format_underline",link:"link_2",left:"format_align_left",center:"format_align_middle",right:"format_align_right",justify:"format_align_justify",ul:"nile-ul",ol:"nile-ol",clear:"error"};let g=class extends i{constructor(){super(...arguments),this.value="",this.mentions={},this.content="",this.previewEl=null,this.toolbarEl=null,this.lastRange=null,this.buttonMap=new Map,this.headingSelect=null,this.fontSelect=null,this.colorInput=null,this.bgColorInput=null,this.colorSwatchEl=null,this.bgSwatchEl=null,this.mentionsEl=null,this.onEditorKeydown=t=>{if("Tab"!==t.key)return;t.preventDefault(),this.focusAndRestore();const i=window.getSelection();if(!i||0===i.rangeCount)return;const s=i.getRangeAt(0);if(t.shiftKey){if(s.collapsed&&s.startContainer.nodeType===Node.TEXT_NODE){const t=s.startContainer,e=s.startOffset,n=t.data.slice(0,e),o=n.replace(/(\t|[ \u00a0]{2})$/,"");if(o.length!==n.length){t.data=o+t.data.slice(e);const s=document.createRange();s.setStart(t,o.length),s.collapse(!0),i.removeAllRanges(),i.addRange(s),this.updateContent(),this.updateToolbarState()}}return}s.deleteContents();const e=document.createTextNode("\t");s.insertNode(e);const n=document.createRange();n.setStartAfter(e),n.collapse(!0),i.removeAllRanges(),i.addRange(n),this.updateContent(),this.updateToolbarState()},this.onSelectionChange=()=>{if(!this.editorEl)return;const t=document.getSelection();if(!t||0===t.rangeCount)return;const i=t.getRangeAt(0);this.editorEl.contains(i.commonAncestorContainer)&&(this.lastRange=i.cloneRange(),this.updateToolbarState())}}createRenderRoot(){return this}shouldUpdate(){return!1}injectCss(t){if(this.querySelector("style[data-rte-style]"))return;const i=document.createElement("style");i.setAttribute("data-rte-style","true"),i.textContent=t,this.insertBefore(i,this.firstChild)}connectedCallback(){super.connectedCallback(),this.injectCss(p.cssText),this.toolbarEl=this.querySelector("nile-rte-toolbar"),this.previewEl=this.querySelector("nile-rte-preview"),this.ensureEditor(),this.value&&!this.editorEl.innerHTML.trim()&&(this.editorEl.innerHTML=this.value),this.content=this.editorEl.innerHTML,this.toolbarEl&&this.wireAuthoredToolbar(this.toolbarEl),this.mentionsEl=this.querySelector("nile-rte-mentions"),this.mentionsEl&&(this.mentionsEl.attach?.(this.editorEl,this),this.mentionsEl.setExternalConfig?.(this.mentions)),this.wireEditor(),this.updateToolbarState(),this.syncPreview(),document.addEventListener("selectionchange",this.onSelectionChange,!0)}disconnectedCallback(){document.removeEventListener("selectionchange",this.onSelectionChange,!0),this.mentionsEl&&this.mentionsEl.detach&&this.mentionsEl.detach(),super.disconnectedCallback()}ensureEditor(){if(this.editorEl=this.querySelector(".editor"),!this.editorEl){const t=document.createElement("article");t.className="editor",t.setAttribute("contenteditable","true"),this.toolbarEl?.nextSibling?this.insertBefore(t,this.toolbarEl.nextSibling):this.previewEl?this.insertBefore(t,this.previewEl):this.appendChild(t),this.editorEl=t}this.editorEl.innerHTML.trim()||(this.editorEl.innerHTML="<p><br></p>"),this.ensureAtLeastOneParagraph()}wireEditor(){this.editorEl.addEventListener("input",(()=>{this.ensureAtLeastOneParagraph(),this.updateContent()})),this.editorEl.addEventListener("mouseup",(()=>this.saveSelection())),this.editorEl.addEventListener("keyup",(()=>this.saveSelection())),this.editorEl.addEventListener("keydown",this.onEditorKeydown)}wireAuthoredToolbar(t){this.buttonMap.clear(),this.headingSelect=null,this.fontSelect=null,this.colorInput=null,Array.from(t.children).forEach((t=>{const i=t.tagName.toLowerCase();if("nile-rte-select"!==i||"align"!==t.getAttribute("type")){if("nile-rte-toolbar-item"===i){let i=t.querySelector(":scope > nile-button");const s=t.getAttribute("name")||"",e=t.getAttribute("label")||s,n=t.getAttribute("icon"),o=t.innerHTML.trim().length>0;if(i||(i=document.createElement("nile-button"),i.variant="tertiary",i.size="small"),n)i.innerHTML=`<nile-icon name="${n}" aria-label="${e}"></nile-icon>`,t.innerHTML="";else if(o)i.innerHTML=t.innerHTML,t.innerHTML="";else{const n=b[s];n?i.innerHTML=`<nile-icon name="${n}" size="20" color="black" aria-label="${e}"></nile-icon>`:i.textContent=e||s,t.innerHTML=""}i.isConnected||t.appendChild(i),i.setAttribute("aria-label",e),i.addEventListener("mousedown",(t=>t.preventDefault())),i.addEventListener("click",(()=>this.onToolbarCommand(s)));const r=this.buttonMap.get(s)??[];return r.push(i),void this.buttonMap.set(s,r)}if("nile-rte-select"!==i){if("nile-rte-color"===i){const i=t.getAttribute("label")??"Text color",s=t.getAttribute("value")??"#000000",e=t.getAttribute("mode")??"text";let n=t.querySelector(':scope > input[type="color"]');n||(n=document.createElement("input"),n.type="color",n.style.position="absolute",n.style.opacity="0",n.style.pointerEvents="none",t.appendChild(n)),n.title=i,n.value=s;let o=t.querySelector(":scope > button.rte-color-trigger");o||(o=document.createElement("button"),o.type="button",o.className="rte-color-trigger",o.setAttribute("aria-label",i),o.innerHTML="background"===e?'\n <span class="swatch-box" aria-hidden="true"></span>\n ':'\n <span class="glyph-stack" aria-hidden="true">\n <span class="glyph">A</span>\n <span class="underline"></span>\n </span>\n ',t.appendChild(o));const r=o.querySelector(".underline"),h=o.querySelector(".swatch-box");"background"===e?(this.bgColorInput=n,this.bgSwatchEl=h,this.bgSwatchEl&&(this.bgSwatchEl.style.backgroundColor=n.value)):(this.colorInput=n,this.colorSwatchEl=r,this.colorSwatchEl&&(this.colorSwatchEl.style.backgroundColor=n.value)),o.addEventListener("click",(t=>{t.preventDefault(),this.focusAndRestore(),n.click()})),n.addEventListener("input",(()=>{this.focusAndRestore(),"background"===e?(l(this.editorEl,n.value),this.bgSwatchEl&&(this.bgSwatchEl.style.backgroundColor=n.value)):(c(this.editorEl,n.value),this.colorSwatchEl&&(this.colorSwatchEl.style.backgroundColor=n.value)),this.updateContent(),this.updateToolbarState()})),o.addEventListener("mousedown",(t=>t.preventDefault())),n.addEventListener("mousedown",(t=>t.preventDefault()))}}else{const i=t.getAttribute("type")||"";t.addEventListener("change",(t=>{this.focusAndRestore();const s=t.detail;"heading"===i?r(this.editorEl,s):"font"===i&&h(this.editorEl,s),this.updateContent(),this.updateToolbarState()}))}}else t.addEventListener("change",(t=>{this.focusAndRestore();const i=t.detail;o(this.editorEl,i),this.updateContent(),this.updateToolbarState()}))}))}saveSelection(){const t=window.getSelection();t&&t.rangeCount&&(this.lastRange=t.getRangeAt(0).cloneRange())}restoreSelection(){if(!this.lastRange)return;const t=document.getSelection();t&&(t.removeAllRanges(),t.addRange(this.lastRange))}focusAndRestore(){this.editorEl?.focus(),this.restoreSelection()}insertList(t){if(this.restoreSelection(),!this.lastRange)return;const i=document.createElement(t),s=this.lastRange.extractContents(),e=document.createElement("div");e.appendChild(s),Array.from(e.childNodes).forEach((t=>{if(t.nodeType===Node.TEXT_NODE&&!t.textContent?.trim())return;const s=document.createElement("li");s.appendChild(t),i.appendChild(s)})),this.lastRange.insertNode(i),this.afterListEdit(i)}afterListEdit(t){const i=document.createRange();i.setStartAfter(t),i.collapse(!0);const s=window.getSelection();s?.removeAllRanges(),s?.addRange(i),this.saveSelection(),this.updateContent(),this.updateToolbarState()}ensureAtLeastOneParagraph(){const t=this.editorEl;if(!t)return;const i=""===(t.textContent??"").replace(/\u200B/g,"").trim();if(0===t.childNodes.length||i)return void(t.innerHTML="<p><br></p>");if(!t.querySelector("p,h1,h2,h3,h4,h5,h6,ul,ol,table,blockquote,pre")){const i=document.createElement("p");for(;t.firstChild;)i.appendChild(t.firstChild);return i.hasChildNodes()||i.appendChild(document.createElement("br")),void t.appendChild(i)}t.querySelectorAll("p").forEach((t=>{""===(t.textContent??"").replace(/\u200B/g,"")&&(t.innerHTML.toLowerCase().includes("<br")||(t.innerHTML="<br>"))}))}onToolbarCommand(t){switch(this.focusAndRestore(),t){case"bold":u(this.editorEl,"strong");break;case"italic":u(this.editorEl,"em");break;case"underline":u(this.editorEl,"u");break;case"left":o(this.editorEl,"left");break;case"center":o(this.editorEl,"center");break;case"right":o(this.editorEl,"right");break;case"justify":o(this.editorEl,"justify");break;case"ul":this.insertList("ul");break;case"ol":this.insertList("ol");break;case"link":a(this.editorEl);break;case"clear":const t=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),i=[];for(;t.nextNode();){const s=t.currentNode;s.removeAttribute("style"),["B","STRONG","I","EM","U","SPAN","FONT"].includes(s.tagName)&&i.push(s)}for(const t of i){for(;t.firstChild;)t.parentNode?.insertBefore(t.firstChild,t);t.remove()}this.ensureAtLeastOneParagraph()}this.updateContent(),this.updateToolbarState()}setBtnActive(t,i){const s=this.buttonMap.get(t);if(s)for(const t of s)t.toggleAttribute("data-active",!!i)}updateToolbarState(){if(!this.editorEl)return;const t=document.getSelection();if(!t||0===t.rangeCount)return;const i=t.getRangeAt(0);if(!this.editorEl.contains(i.commonAncestorContainer))return;const s=d(i.startContainer)||this.editorEl,e=getComputedStyle(s),n=f(i.startContainer,this.editorEl)||this.editorEl,o=(()=>{let t=s;for(;t&&t!==this.editorEl;){if(t instanceof HTMLElement){const i=t.tagName.toLowerCase();if("strong"===i||"b"===i)return!0;const s=getComputedStyle(t).fontWeight;if(parseInt(s,10)>=600)return!0}t=t.parentNode}return!1})(),r=(()=>{let t=s;for(;t&&t!==this.editorEl;){if(t instanceof HTMLElement){const i=t.tagName.toLowerCase();if("em"===i||"i"===i)return!0;if("italic"===getComputedStyle(t).fontStyle)return!0}t=t.parentNode}return!1})(),h=(()=>{let t=s;for(;t&&t!==this.editorEl;){if(t instanceof HTMLElement){const i=getComputedStyle(t).textDecorationLine;if(i&&i.includes("underline"))return!0;if("u"===t.tagName.toLowerCase())return!0}t=t.parentNode}return!1})(),l=!!s.closest("a"),c=n.style.textAlign||getComputedStyle(n).textAlign||"start",a="start"===c?"left":c,u=!!s.closest("li")&&s.closest("ul,ol")?.tagName.toLowerCase()||"";if(this.setBtnActive("bold",o),this.setBtnActive("italic",r),this.setBtnActive("underline",h),this.setBtnActive("link",l),this.setBtnActive("left","left"===a&&!["center","right","justify"].includes(a)),this.setBtnActive("center","center"===a),this.setBtnActive("right","right"===a),this.setBtnActive("justify","justify"===a),this.setBtnActive("ul","ul"===u),this.setBtnActive("ol","ol"===u),this.headingSelect){const t=n.tagName.toLowerCase(),i=["h1","h2","h3"].includes(t)?t:"p";this.headingSelect.value!==i&&(this.headingSelect.value=i)}if(this.fontSelect){const t=(e.fontFamily||"").replace(/["']/g,"").split(",")[0].trim().toLowerCase();if(t)for(const i of Array.from(this.fontSelect.options))if(i.value.toLowerCase()===t){this.fontSelect.value=i.value;break}}if(this.colorInput){const t=m(e.color);t&&this.colorInput.value.toLowerCase()!==t.toLowerCase()&&(this.colorInput.value=t),this.colorSwatchEl&&(this.colorSwatchEl.style.backgroundColor=this.colorInput.value)}if(this.bgColorInput){const t=getComputedStyle(s).backgroundColor;if(t&&!/transparent|rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0\s*\)/i.test(t)){const i=m(t);i&&this.bgColorInput.value.toLowerCase()!==i.toLowerCase()&&(this.bgColorInput.value=i)}this.bgSwatchEl&&(this.bgSwatchEl.style.backgroundColor=this.bgColorInput.value)}}syncPreview(){this.updateContent()}updateContent(){if(!this.editorEl)return;this.ensureAtLeastOneParagraph();const t=this.editorEl.cloneNode(!0),i=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;i.nextNode()&&s.nextNode();){const t=i.currentNode,e=s.currentNode,n=window.getComputedStyle(t),o=Array.from(n).map((t=>`${t}:${n.getPropertyValue(t)}`)).join(";");e.setAttribute("style",o)}this.content=t.innerHTML,this.previewEl&&(this.previewEl.innerHTML=this.content),this.dispatchEvent(new CustomEvent("content-changed",{detail:{content:this.content},bubbles:!0,composed:!0}))}};t([s({type:String})],g.prototype,"value",void 0),t([s({attribute:"mentions",converter:{fromAttribute:t=>{try{const i=JSON.parse(t),s={};for(const t of Object.keys(i)){const e=i[t];Array.isArray(e)&&(s[t]=e.filter((t=>t&&"string"==typeof t.key&&"string"==typeof t.label)).map((t=>({key:t.key,label:t.label}))))}return s}catch{return{}}},toAttribute:t=>JSON.stringify(t)}})],g.prototype,"mentions",void 0),t([e()],g.prototype,"content",void 0),g=t([n("nile-rich-text-editor")],g);export{g as N};
|
1
|
+
import{__decorate as t}from"tslib";import{LitElement as i}from"lit";import{property as s,state as e,customElement as n}from"lit/decorators.js";import"./nile-rte-toolbar.esm.js";import"./nile-rte-toolbar-item.esm.js";import"./nile-rte-select.esm.js";import"./nile-rte-color.esm.js";import"./nile-rte-divider.esm.js";import"./nile-rte-preview.esm.js";import"./nile-rte-mentions.esm.js";import"./nile-rte-link.esm.js";import{s as r,a as o,b as h,c as l,d as c,t as a,n as u,e as f,r as d}from"./utils.esm.js";import{s as m}from"./nile-rich-text-editor.css.esm.js";const b={bold:"format_bold",italic:"format_italic",underline:"format_underline",link:"link_2",left:"format_align_left",center:"format_align_middle",right:"format_align_right",justify:"format_align_justify",ul:"format_list_bulleted",ol:"format_list_numbered",clear:"format_clear"};let p=class extends i{constructor(){super(...arguments),this.value="",this.mentions={},this.content="",this.previewEl=null,this.toolbarEl=null,this.lastRange=null,this.buttonMap=new Map,this.headingSelect=null,this.fontSelect=null,this.colorInput=null,this.bgColorInput=null,this.colorSwatchEl=null,this.bgSwatchEl=null,this.mentionsEl=null,this.onEditorKeydown=t=>{if("Tab"!==t.key)return;t.preventDefault(),this.focusAndRestore();const i=window.getSelection();if(!i||0===i.rangeCount)return;const s=i.getRangeAt(0);if(t.shiftKey){if(s.collapsed&&s.startContainer.nodeType===Node.TEXT_NODE){const t=s.startContainer,e=s.startOffset,n=t.data.slice(0,e),r=n.replace(/(\t|[ \u00a0]{2})$/,"");if(r.length!==n.length){t.data=r+t.data.slice(e);const s=document.createRange();s.setStart(t,r.length),s.collapse(!0),i.removeAllRanges(),i.addRange(s),this.updateContent(),this.updateToolbarState()}}return}s.deleteContents();const e=document.createTextNode("\t");s.insertNode(e);const n=document.createRange();n.setStartAfter(e),n.collapse(!0),i.removeAllRanges(),i.addRange(n),this.updateContent(),this.updateToolbarState()},this.onSelectionChange=()=>{if(!this.editorEl)return;const t=document.getSelection();if(!t||0===t.rangeCount)return;const i=t.getRangeAt(0);this.editorEl.contains(i.commonAncestorContainer)&&(this.lastRange=i.cloneRange(),this.updateToolbarState())}}createRenderRoot(){return this}shouldUpdate(){return!1}injectCss(t){if(this.querySelector("style[data-rte-style]"))return;const i=document.createElement("style");i.setAttribute("data-rte-style","true"),i.textContent=t,this.insertBefore(i,this.firstChild)}connectedCallback(){super.connectedCallback(),this.injectCss(m.cssText),this.toolbarEl=this.querySelector("nile-rte-toolbar"),this.previewEl=this.querySelector("nile-rte-preview"),this.ensureEditor(),this.value&&!this.editorEl.innerHTML.trim()&&(this.editorEl.innerHTML=this.value),this.content=this.editorEl.innerHTML,this.toolbarEl&&this.wireAuthoredToolbar(this.toolbarEl),this.mentionsEl=this.querySelector("nile-rte-mentions"),this.mentionsEl&&(this.mentionsEl.attach?.(this.editorEl,this),this.mentionsEl.setExternalConfig?.(this.mentions)),this.wireEditor(),this.updateToolbarState(),this.syncPreview(),document.addEventListener("selectionchange",this.onSelectionChange,!0)}disconnectedCallback(){document.removeEventListener("selectionchange",this.onSelectionChange,!0),this.mentionsEl&&this.mentionsEl.detach&&this.mentionsEl.detach(),super.disconnectedCallback()}ensureEditor(){if(this.editorEl=this.querySelector(".editor"),!this.editorEl){const t=document.createElement("article");t.className="editor",t.setAttribute("contenteditable","true"),this.toolbarEl?.nextSibling?this.insertBefore(t,this.toolbarEl.nextSibling):this.previewEl?this.insertBefore(t,this.previewEl):this.appendChild(t),this.editorEl=t}this.editorEl.innerHTML.trim()||(this.editorEl.innerHTML="<p><br></p>"),this.ensureAtLeastOneParagraph()}wireEditor(){this.editorEl.addEventListener("input",(()=>{this.ensureAtLeastOneParagraph(),this.updateContent()})),this.editorEl.addEventListener("mouseup",(()=>this.saveSelection())),this.editorEl.addEventListener("keyup",(()=>this.saveSelection())),this.editorEl.addEventListener("keydown",this.onEditorKeydown)}wireAuthoredToolbar(t){this.buttonMap.clear(),this.headingSelect=null,this.fontSelect=null,this.colorInput=null,Array.from(t.children).forEach((t=>{const i=t.tagName.toLowerCase();if("nile-rte-select"!==i||"align"!==t.getAttribute("type")){if("nile-rte-link"===i)return t.editorEl=this.editorEl,void t.addEventListener("link-changed",(()=>{this.updateContent(),this.updateToolbarState()}));if("nile-rte-toolbar-item"===i){let i=t.querySelector(":scope > nile-button");const s=t.getAttribute("name")||"",e=t.getAttribute("label")||s,n=t.getAttribute("icon"),r=t.innerHTML.trim().length>0;if(i||(i=document.createElement("nile-button"),i.variant="tertiary",i.size="small"),n)i.innerHTML=`<nile-icon name="${n}" aria-label="${e}"></nile-icon>`,t.innerHTML="";else if(r)i.innerHTML=t.innerHTML,t.innerHTML="";else{const n=b[s];n?i.innerHTML=`<nile-icon name="${n}" size="20" color="black" aria-label="${e}"></nile-icon>`:i.textContent=e||s,t.innerHTML=""}i.isConnected||t.appendChild(i),i.setAttribute("aria-label",e),i.addEventListener("mousedown",(t=>t.preventDefault())),i.addEventListener("click",(()=>this.onToolbarCommand(s)));const o=this.buttonMap.get(s)??[];return o.push(i),void this.buttonMap.set(s,o)}if("nile-rte-select"!==i)"nile-rte-color"!==i||t.addEventListener("change",(t=>{this.focusAndRestore();const{mode:i,value:s}=t.detail;"backColor"===i?l(this.editorEl,s):c(this.editorEl,s),this.updateContent(),this.updateToolbarState()}));else{const i=t.getAttribute("type")||"";t.addEventListener("change",(t=>{this.focusAndRestore();const s=t.detail;"heading"===i?o(this.editorEl,s):"font"===i&&h(this.editorEl,s),this.updateContent(),this.updateToolbarState()}))}}else t.addEventListener("change",(t=>{this.focusAndRestore();const i=t.detail;r(this.editorEl,i),this.updateContent(),this.updateToolbarState()}))}))}saveSelection(){const t=window.getSelection();t&&t.rangeCount&&(this.lastRange=t.getRangeAt(0).cloneRange())}restoreSelection(){if(!this.lastRange)return;const t=document.getSelection();t&&(t.removeAllRanges(),t.addRange(this.lastRange))}focusAndRestore(){this.editorEl?.focus(),this.restoreSelection()}insertList(t){if(this.restoreSelection(),!this.lastRange)return;const i=document.createElement(t),s=this.lastRange.extractContents(),e=document.createElement("div");e.appendChild(s),Array.from(e.childNodes).forEach((t=>{if(t.nodeType===Node.TEXT_NODE&&!t.textContent?.trim())return;const s=document.createElement("li");s.appendChild(t),i.appendChild(s)})),this.lastRange.insertNode(i),this.afterListEdit(i)}afterListEdit(t){const i=document.createRange();i.setStartAfter(t),i.collapse(!0);const s=window.getSelection();s?.removeAllRanges(),s?.addRange(i),this.saveSelection(),this.updateContent(),this.updateToolbarState()}ensureAtLeastOneParagraph(){const t=this.editorEl;if(!t)return;const i=""===(t.textContent??"").replace(/\u200B/g,"").trim();if(0===t.childNodes.length||i)return void(t.innerHTML="<p><br></p>");if(!t.querySelector("p,h1,h2,h3,h4,h5,h6,ul,ol,table,blockquote,pre")){const i=document.createElement("p");for(;t.firstChild;)i.appendChild(t.firstChild);return i.hasChildNodes()||i.appendChild(document.createElement("br")),void t.appendChild(i)}t.querySelectorAll("p").forEach((t=>{""===(t.textContent??"").replace(/\u200B/g,"")&&(t.innerHTML.toLowerCase().includes("<br")||(t.innerHTML="<br>"))}))}onToolbarCommand(t){switch(this.focusAndRestore(),t){case"bold":a(this.editorEl,"strong");break;case"italic":a(this.editorEl,"em");break;case"underline":a(this.editorEl,"u");break;case"left":r(this.editorEl,"left");break;case"center":r(this.editorEl,"center");break;case"right":r(this.editorEl,"right");break;case"justify":r(this.editorEl,"justify");break;case"ul":this.insertList("ul");break;case"ol":this.insertList("ol");break;case"link":break;case"clear":const t=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),i=[];for(;t.nextNode();){const s=t.currentNode;s.removeAttribute("style"),["B","STRONG","I","EM","U","SPAN","FONT"].includes(s.tagName)&&i.push(s)}for(const t of i){for(;t.firstChild;)t.parentNode?.insertBefore(t.firstChild,t);t.remove()}this.ensureAtLeastOneParagraph()}this.updateContent(),this.updateToolbarState()}setBtnActive(t,i){const s=this.buttonMap.get(t);if(s)for(const t of s)t.toggleAttribute("data-active",!!i)}updateToolbarState(){if(!this.editorEl)return;const t=document.getSelection();if(!t||0===t.rangeCount)return;const i=t.getRangeAt(0);if(!this.editorEl.contains(i.commonAncestorContainer))return;const s=u(i.startContainer)||this.editorEl,e=getComputedStyle(s),n=f(i.startContainer,this.editorEl)||this.editorEl,r=(()=>{let t=s;for(;t&&t!==this.editorEl;){if(t instanceof HTMLElement){const i=t.tagName.toLowerCase();if("strong"===i||"b"===i)return!0;const s=getComputedStyle(t).fontWeight;if(parseInt(s,10)>=600)return!0}t=t.parentNode}return!1})(),o=(()=>{let t=s;for(;t&&t!==this.editorEl;){if(t instanceof HTMLElement){const i=t.tagName.toLowerCase();if("em"===i||"i"===i)return!0;if("italic"===getComputedStyle(t).fontStyle)return!0}t=t.parentNode}return!1})(),h=(()=>{let t=s;for(;t&&t!==this.editorEl;){if(t instanceof HTMLElement){const i=getComputedStyle(t).textDecorationLine;if(i&&i.includes("underline"))return!0;if("u"===t.tagName.toLowerCase())return!0}t=t.parentNode}return!1})(),l=!!s.closest("a"),c=n.style.textAlign||getComputedStyle(n).textAlign||"start",a="start"===c?"left":c,m=!!s.closest("li")&&s.closest("ul,ol")?.tagName.toLowerCase()||"";if(this.setBtnActive("bold",r),this.setBtnActive("italic",o),this.setBtnActive("underline",h),this.setBtnActive("link",l),this.setBtnActive("left","left"===a&&!["center","right","justify"].includes(a)),this.setBtnActive("center","center"===a),this.setBtnActive("right","right"===a),this.setBtnActive("justify","justify"===a),this.setBtnActive("ul","ul"===m),this.setBtnActive("ol","ol"===m),this.headingSelect){const t=n.tagName.toLowerCase(),i=["h1","h2","h3"].includes(t)?t:"p";this.headingSelect.value!==i&&(this.headingSelect.value=i)}if(this.fontSelect){const t=(e.fontFamily||"").replace(/["']/g,"").split(",")[0].trim().toLowerCase();if(t)for(const i of Array.from(this.fontSelect.options))if(i.value.toLowerCase()===t){this.fontSelect.value=i.value;break}}if(this.colorInput){const t=d(e.color);t&&this.colorInput.value.toLowerCase()!==t.toLowerCase()&&(this.colorInput.value=t),this.colorSwatchEl&&(this.colorSwatchEl.style.backgroundColor=this.colorInput.value)}if(this.bgColorInput){const t=getComputedStyle(s).backgroundColor;if(t&&!/transparent|rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0\s*\)/i.test(t)){const i=d(t);i&&this.bgColorInput.value.toLowerCase()!==i.toLowerCase()&&(this.bgColorInput.value=i)}this.bgSwatchEl&&(this.bgSwatchEl.style.backgroundColor=this.bgColorInput.value)}}syncPreview(){this.updateContent()}updateContent(){if(!this.editorEl)return;this.ensureAtLeastOneParagraph();const t=this.editorEl.cloneNode(!0),i=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT),e=["font-weight","font-style","text-decoration","color","background-color","font-size","font-family","text-align","line-height","letter-spacing","white-space","vertical-align"];for(;i.nextNode()&&s.nextNode();){const t=i.currentNode,n=s.currentNode,r=window.getComputedStyle(t),o=e.map((t=>`${t}:${r.getPropertyValue(t)}`)).join(";");o.trim()&&n.setAttribute("style",o)}this.content=t.innerHTML,this.previewEl&&(this.previewEl.innerHTML=this.content),this.dispatchEvent(new CustomEvent("content-changed",{detail:{content:this.content},bubbles:!0,composed:!0}))}};t([s({type:String})],p.prototype,"value",void 0),t([s({attribute:"mentions",converter:{fromAttribute:t=>{try{const i=JSON.parse(t),s={};for(const t of Object.keys(i)){const e=i[t];Array.isArray(e)&&(s[t]=e.filter((t=>t&&"string"==typeof t.key&&"string"==typeof t.label)).map((t=>({key:t.key,label:t.label}))))}return s}catch{return{}}},toAttribute:t=>JSON.stringify(t)}})],p.prototype,"mentions",void 0),t([e()],p.prototype,"content",void 0),p=t([n("nile-rich-text-editor")],p);export{p as N};
|
@@ -1,2 +1,2 @@
|
|
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);}System.register(["tslib","lit","lit/decorators.js"],function(_export,_context){"use strict";var t,r,o,e,i;function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}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);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){r=_lit.LitElement;},function(_litDecoratorsJs){o=_litDecoratorsJs.property;e=_litDecoratorsJs.customElement;}],execute:function execute(){i=/*#__PURE__*/function(_r){function i(){var _this;_classCallCheck(this,i);_this=_callSuper(this,i,arguments),_this.type="foreColor",_this.label="Text Color",_this.value="#000000";return _this;}_inherits(i,_r);return _createClass(i,[{key:"createRenderRoot",value:function createRenderRoot(){return this;}},{key:"shouldUpdate",value:function shouldUpdate(){return!1;}}]);}(r);t([o({type:String})],i.prototype,"type",void 0),t([o({type:String})],i.prototype,"label",void 0),t([o({type:String})],i.prototype,"value",void 0),i=t([e("nile-rte-color")],i);}};});
|
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);}System.register(["tslib","lit","lit/decorators.js"],function(_export,_context){"use strict";var t,s,n,i,e,o,_templateObject,_templateObject2,_templateObject3,_templateObject4,_templateObject5,_templateObject6,_templateObject7,a;function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread();}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}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;}}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r);}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r);}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;}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}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);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){s=_lit.LitElement;n=_lit.html;},function(_litDecoratorsJs){i=_litDecoratorsJs.property;e=_litDecoratorsJs.state;o=_litDecoratorsJs.customElement;}],execute:function execute(){a=/*#__PURE__*/function(_s){function a(){var _this;_classCallCheck(this,a);_this=_callSuper(this,a,arguments),_this.mode="foreColor",_this.label="Text Color",_this.value="#000000",_this.palette=["#000000","#444444","#666666","#999999","#cccccc","#eeeeee","#ffffff","#d32f2f","#f44336","#ff9800","#ffeb3b","#4caf50","#2196f3","#3f51b5","#9c27b0","#03a9f4","#00bcd4","#009688","#8bc34a","#cddc39","#ffc107","#ff5722"],_this.recentColors=[],_this.pickCustom=function(){return _this.inputEl.click();};return _this;}_inherits(a,_s);return _createClass(a,[{key:"createRenderRoot",value:function createRenderRoot(){return this;}},{key:"connectedCallback",value:function connectedCallback(){var _this2=this;_superPropGet(a,"connectedCallback",this,3)([]),this.injectCss("\n nile-button.rte-color-trigger::part(base){\n width:32px; height:32px; padding:0px 6px;\n }\n\n .glyph-stack { display:grid; align-items:center; justify-items:center; line-height:1; }\n .glyph { font-size:14px; margin-bottom:2px; }\n .underline { width:18px; height:3px; border-radius:2px; }\n .swatch-box { width:18px; height:16px; border-radius:4px; border:1px solid rgba(0,0,0,0.35); }\n\n nile-popover::part(popover) {\n min-width: 225px;\n height: 250px;\n padding: 0px;\n gap: 0px;\n }\n\n .swatch-dropdown {\n height: 245px;\n width: 275px;\n padding: 12px;\n background: #fff;\n border-radius: 8px;\n box-sizing: border-box;\n overflow-y: auto;\n }\n\n .section { margin-bottom: 12px; }\n .title { font-size: 13px; font-weight: 600; margin-bottom: 8px; color:#111; }\n\n .swatches {\n display: grid;\n grid-template-columns: repeat(auto-fill, 24px);\n gap: 8px;\n }\n\n .swatch {\n width: 24px;\n height: 24px;\n border-radius: 50%;\n border: 1px solid rgba(0,0,0,0.25);\n cursor: pointer;\n position: relative;\n background-clip: content-box;\n }\n\n .swatch.add {\n display:flex;\n align-items:center;\n justify-content:center;\n font-weight:bold;\n font-size:16px;\n background:#fff;\n }\n\n .checkmark {\n position: absolute;\n top: 50%; left: 50%;\n transform: translate(-50%,-50%);\n font-size: 13px;\n color: white;\n text-shadow: 0 0 2px rgba(0,0,0,0.6);\n }\n "),this.inputEl=document.createElement("input"),this.inputEl.type="color",this.inputEl.style.position="absolute",this.inputEl.style.opacity="0",this.inputEl.style.pointerEvents="none",this.inputEl.value=this.value,this.appendChild(this.inputEl),this.inputEl.addEventListener("input",function(){return _this2.setColor(_this2.inputEl.value);});}},{key:"injectCss",value:function injectCss(t){if(this.querySelector("style[data-rte-color-style]"))return;var s=document.createElement("style");s.setAttribute("data-rte-color-style","true"),s.textContent=t,this.insertBefore(s,this.firstChild);}},{key:"setColor",value:function setColor(t){this.value=t,this.recentColors=[t].concat(_toConsumableArray(this.recentColors.filter(function(s){return s!==t;}))).slice(0,8),this.dispatchEvent(new CustomEvent("change",{detail:{mode:this.mode,value:t},bubbles:!0,composed:!0}));}},{key:"render",value:function render(){var _this3=this;return n(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <nile-popover placement=\"bottom-start\" distance=\"6\" .arrow=",">\n <nile-button\n slot=\"anchor\"\n variant=\"ghost\"\n size=\"small\"\n aria-label=","\n class=\"rte-color-trigger\"\n >\n ","\n </nile-button>\n\n <div part=\"base\" class=\"swatch-dropdown\">\n <div class=\"section\">\n <div class=\"title\">Default</div>\n <div class=\"swatches\">\n ","\n </div>\n </div>\n\n ","\n\n <div class=\"section\">\n <div class=\"title\">Custom</div>\n <div class=\"swatches\">\n <button class=\"swatch add\" @click=",">+</button>\n <nile-icon name=\"eyedropper\"></nile-icon>\n </div>\n </div>\n </div>\n </nile-popover>\n "])),!1,this.label,"backColor"===this.mode?n(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["<span class=\"swatch-box\" style=\"background:","\"></span>"])),this.value):n(_templateObject3||(_templateObject3=_taggedTemplateLiteral(["\n <span class=\"glyph-stack\">\n <span class=\"glyph\">A</span>\n <span class=\"underline\" style=\"background:","\"></span>\n </span>\n "])),this.value),this.palette.map(function(t){return n(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["\n <button class=\"swatch\" style=\"background:","\"\n @click=","\n title=",">\n ","\n </button>\n "])),t,function(){return _this3.setColor(t);},t,_this3.value===t?n(_templateObject5||(_templateObject5=_taggedTemplateLiteral(["<span class=\"checkmark\">\u2713</span>"]))):"");}),this.recentColors.length>0?n(_templateObject6||(_templateObject6=_taggedTemplateLiteral(["\n <div class=\"section\">\n <div class=\"title\">Recently Used</div>\n <div class=\"swatches\">\n ","\n </div>\n </div>\n "])),this.recentColors.map(function(t){return n(_templateObject7||(_templateObject7=_taggedTemplateLiteral(["\n <button class=\"swatch\" style=\"background:","\"\n @click=","\n title=","></button>\n "])),t,function(){return _this3.setColor(t);},t);})):"",this.pickCustom);}}]);}(s);t([i({type:String})],a.prototype,"mode",void 0),t([i({type:String})],a.prototype,"label",void 0),t([i({type:String})],a.prototype,"value",void 0),t([i({type:Array})],a.prototype,"palette",void 0),t([e()],a.prototype,"recentColors",void 0),a=t([o("nile-rte-color")],a);}};});
|
2
2
|
//# sourceMappingURL=nile-rte-color.cjs.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-rte-color.cjs.js","sources":["../../../src/nile-rich-text-editor/nile-rte-color.ts"],"sourcesContent":["import { LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\n@customElement('nile-rte-color')\nexport class NileRteColor extends LitElement {\n protected createRenderRoot() { return this; }\n protected shouldUpdate() { return false; }\n\n /** 'foreColor' (reserved for future: 'backColor') */\n @property({ type: String }) type = 'foreColor';\n @property({ type: String }) label = 'Text Color';\n @property({ type: String }) value = '#000000';\n}\ndeclare global { interface HTMLElementTagNameMap { 'nile-rte-color': NileRteColor; } }\n"],"names":["NileRteColor","_r","i","this","type","label","value","_this","_inherits","_createClass","key","createRenderRoot","shouldUpdate","LitElement","__decorate","property","String","prototype","customElement"],"mappings":"gyFAIaA,CAAN,uBAAAC,EAAA,EAAA,SAAAC,EAAA,uEAKuBC,KAAAA,CAAIC,IAAAA,CAAG,WACPD,CAAAA,KAAAA,CAAKE,KAAG,CAAA,YAAA,CACRF,KAAAA,CAAKG,KAAAA,CAAG,SACrC,QAAAC,KAAA,EAPWC,SAAA,CAAAN,CAAA,CAAAD,EAAA,SAAAQ,YAAA,CAAAP,CAAA,GAAAQ,GAAA,oBAAAJ,KAAA,UAAAK,gBAAAA,CAAAA,CAAqB,CAAA,MAAOR,KAAO,EACnC,GAAAO,GAAA,gBAAAJ,KAAA,UAAAM,YAAAA,CAAAA,CAAAA,CAAiB,OAAO,CAAQ,EAAA,MAFVC,CAA3B,EAKuBC,CAAA,CAAA,CAA3BC,CAAS,CAAA,CAAEX,IAAMY,CAAAA,MAAAA,CAAAA,CAAAA,CAAAA,CAA6BhB,EAAAiB,SAAA,CAAA,MAAA,CAAA,IAAA,EACnBH,CAAAA,CAAAA,CAAAA,CAAA,CAA3BC,CAAAA,CAAS,CAAEX,IAAAA,CAAMY,UAA+BhB,CAAAiB,CAAAA,SAAAA,CAAA,OAAA,CAAA,IAAA,EAAA,CAAA,CACrBH,CAAA,CAAA,CAA3BC,CAAS,CAAA,CAAEX,KAAMY,MAA4BhB,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAiB,SAAA,CAAA,OAAA,CAAA,IAAA,EAPnCjB,CAAAA,CAAAA,CAAAA,CAAYc,CAAA,CAAA,CADxBI,EAAc,gBACFlB,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA"}
|
1
|
+
{"version":3,"file":"nile-rte-color.cjs.js","sources":["../../../src/nile-rich-text-editor/nile-rte-color.ts"],"sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\n\n@customElement('nile-rte-color')\nexport class NileRteColor extends LitElement {\n protected createRenderRoot() { return this; }\n\n /** Whether this is text color or background color */\n @property({ type: String }) mode: 'foreColor' | 'backColor' = 'foreColor';\n @property({ type: String }) label = 'Text Color';\n @property({ type: String }) value = '#000000';\n\n /** Default palette, user can override via property or attribute */\n @property({ type: Array })\n palette: string[] = [\n '#000000','#444444','#666666','#999999','#cccccc','#eeeeee','#ffffff',\n '#d32f2f','#f44336','#ff9800','#ffeb3b','#4caf50','#2196f3','#3f51b5','#9c27b0',\n '#03a9f4','#00bcd4','#009688','#8bc34a','#cddc39','#ffc107','#ff5722'\n ];\n\n @state() private recentColors: string[] = [];\n private inputEl!: HTMLInputElement;\n\n connectedCallback() {\n super.connectedCallback();\n\n // Inject styles once\n this.injectCss(`\n nile-button.rte-color-trigger::part(base){\n width:32px; height:32px; padding:0px 6px;\n }\n\n .glyph-stack { display:grid; align-items:center; justify-items:center; line-height:1; }\n .glyph { font-size:14px; margin-bottom:2px; }\n .underline { width:18px; height:3px; border-radius:2px; }\n .swatch-box { width:18px; height:16px; border-radius:4px; border:1px solid rgba(0,0,0,0.35); }\n\n nile-popover::part(popover) {\n min-width: 225px;\n height: 250px;\n padding: 0px;\n gap: 0px;\n }\n\n .swatch-dropdown {\n height: 245px;\n width: 275px;\n padding: 12px;\n background: #fff;\n border-radius: 8px;\n box-sizing: border-box;\n overflow-y: auto;\n }\n\n .section { margin-bottom: 12px; }\n .title { font-size: 13px; font-weight: 600; margin-bottom: 8px; color:#111; }\n\n .swatches {\n display: grid;\n grid-template-columns: repeat(auto-fill, 24px);\n gap: 8px;\n }\n\n .swatch {\n width: 24px;\n height: 24px;\n border-radius: 50%;\n border: 1px solid rgba(0,0,0,0.25);\n cursor: pointer;\n position: relative;\n background-clip: content-box;\n }\n\n .swatch.add {\n display:flex;\n align-items:center;\n justify-content:center;\n font-weight:bold;\n font-size:16px;\n background:#fff;\n }\n\n .checkmark {\n position: absolute;\n top: 50%; left: 50%;\n transform: translate(-50%,-50%);\n font-size: 13px;\n color: white;\n text-shadow: 0 0 2px rgba(0,0,0,0.6);\n }\n `);\n\n // hidden native color input\n this.inputEl = document.createElement('input');\n this.inputEl.type = 'color';\n this.inputEl.style.position = 'absolute';\n this.inputEl.style.opacity = '0';\n this.inputEl.style.pointerEvents = 'none';\n this.inputEl.value = this.value;\n this.appendChild(this.inputEl);\n\n this.inputEl.addEventListener('input', () => this.setColor(this.inputEl.value));\n }\n\n private injectCss(cssText: string) {\n if (this.querySelector('style[data-rte-color-style]')) return;\n const style = document.createElement('style');\n style.setAttribute('data-rte-color-style', 'true');\n style.textContent = cssText;\n this.insertBefore(style, this.firstChild);\n }\n\n private setColor(color: string) {\n this.value = color;\n this.recentColors = [color, ...this.recentColors.filter(c => c !== color)].slice(0, 8);\n\n this.dispatchEvent(new CustomEvent('change', {\n detail: { mode: this.mode, value: color },\n bubbles: true,\n composed: true\n }));\n }\n\n private pickCustom = () => this.inputEl.click();\n\n render() {\n return html`\n <nile-popover placement=\"bottom-start\" distance=\"6\" .arrow=${false}>\n <nile-button\n slot=\"anchor\"\n variant=\"ghost\"\n size=\"small\"\n aria-label=${this.label}\n class=\"rte-color-trigger\"\n >\n ${this.mode === 'backColor'\n ? html`<span class=\"swatch-box\" style=\"background:${this.value}\"></span>`\n : html`\n <span class=\"glyph-stack\">\n <span class=\"glyph\">A</span>\n <span class=\"underline\" style=\"background:${this.value}\"></span>\n </span>\n `}\n </nile-button>\n\n <div part=\"base\" class=\"swatch-dropdown\">\n <div class=\"section\">\n <div class=\"title\">Default</div>\n <div class=\"swatches\">\n ${this.palette.map(c => html`\n <button class=\"swatch\" style=\"background:${c}\"\n @click=${() => this.setColor(c)}\n title=${c}>\n ${this.value === c ? html`<span class=\"checkmark\">✓</span>` : ''}\n </button>\n `)}\n </div>\n </div>\n\n ${this.recentColors.length > 0 ? html`\n <div class=\"section\">\n <div class=\"title\">Recently Used</div>\n <div class=\"swatches\">\n ${this.recentColors.map(c => html`\n <button class=\"swatch\" style=\"background:${c}\"\n @click=${() => this.setColor(c)}\n title=${c}></button>\n `)}\n </div>\n </div>\n ` : ''}\n\n <div class=\"section\">\n <div class=\"title\">Custom</div>\n <div class=\"swatches\">\n <button class=\"swatch add\" @click=${this.pickCustom}>+</button>\n <nile-icon name=\"eyedropper\"></nile-icon>\n </div>\n </div>\n </div>\n </nile-popover>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-rte-color': NileRteColor;\n }\n}\n"],"names":["NileRteColor","a","this","mode","label","value","palette","recentColors","pickCustom","inputEl","click","_this","_inherits","_s","_createClass","key","createRenderRoot","connectedCallback","super","injectCss","document","createElement","type","style","position","opacity","pointerEvents","appendChild","addEventListener","setColor","cssText","querySelector","setAttribute","textContent","insertBefore","firstChild","color","filter","c","slice","dispatchEvent","CustomEvent","detail","bubbles","composed","render","html","_templateObject","_taggedTemplateLiteral","_templateObject2","_templateObject3","map","_templateObject4","_templateObject5","length","_templateObject6","_templateObject7","__decorate","LitElement","property","String","prototype","Array","state","customElement"],"mappings":"2iJAIaA,4BAAN,SAAAC,EAAA,uEAIuBC,KAAAA,CAAIC,IAAAA,CAA8B,YAClCD,KAAAA,CAAKE,KAAAA,CAAG,YACRF,CAAAA,KAAAA,CAAKG,MAAG,SAIpCH,CAAAA,KAAAA,CAAAI,QAAoB,CAClB,SAAA,CAAU,UAAU,SAAU,CAAA,SAAA,CAAU,UAAU,SAAU,CAAA,SAAA,CAC5D,UAAU,SAAU,CAAA,SAAA,CAAU,UAAU,SAAU,CAAA,SAAA,CAAU,UAAU,SACtE,CAAA,SAAA,CAAU,SAAU,CAAA,SAAA,CAAU,UAAU,SAAU,CAAA,SAAA,CAAU,WAG7CJ,KAAAA,CAAYK,YAAAA,CAAa,GAuGlCL,KAAAA,CAAUM,UAAAA,CAAG,iBAAMN,CAAAA,KAAAA,CAAKO,OAAAA,CAAQC,OA4DzC,UAAAC,KAAA,EAlLWC,SAAA,CAAAX,CAAA,CAAAY,EAAA,SAAAC,YAAA,CAAAb,CAAA,GAAAc,GAAA,oBAAAV,KAAA,UAAAW,gBAAAA,CAAAA,EAAqB,MAAOd,KAAO,EAkB7C,GAAAa,GAAA,qBAAAV,KAAA,UAAAY,iBAAAA,CAAAA,CAAAA,KAAAA,MAAAA,MACEC,aAAAA,CAAAA,CAAAA,iCAGAhB,IAAAA,CAAKiB,UAAU,0rDAkEf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A,CAAAA,CAAAA,GACrBA,CAAAA,MAId,EAAA,CAKoCpC,IAAKM,CAAAA,UAAAA,EAOpD,CA9K2BiD,MAJIC,CAAAA,EAIJD,CAAAA,CAAA,CAA3BE,CAAS,CAAA,CAAErC,KAAMsC,MAAwD5D,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA6D,SAAA,CAAA,MAAA,CAAA,IAAA,EAC9CJ,CAAAA,CAAAA,CAAAA,CAAA,CAA3BE,CAAS,CAAA,CAAErC,IAAMsC,CAAAA,MAAAA,CAAAA,CAAAA,CAAAA,CAA+B5D,CAAA6D,CAAAA,SAAAA,CAAA,YAAA,EACrBJ,CAAAA,CAAAA,CAAAA,CAAA,CAA3BE,CAAAA,CAAS,CAAErC,IAAAA,CAAMsC,UAA4B5D,CAAA6D,CAAAA,SAAAA,CAAA,OAAA,CAAA,IAAA,EAAA,CAAA,CAI9CJ,CAAA,CAAA,CADCE,EAAS,CAAErC,IAAAA,CAAMwC,KAKhB9D,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA6D,SAAA,CAAA,SAAA,CAAA,IAAA,IAEeJ,CAAA,CAAA,CAAhBM,CAA4C/D,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA6D,SAAA,CAAA,cAAA,CAAA,IAAA,IAhBlC7D,CAAYyD,CAAAA,CAAAA,CAAA,CADxBO,CAAAA,CAAc,gBACFhE,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA"}
|
@@ -1 +1,54 @@
|
|
1
|
-
import{__decorate as t}from"tslib";import{LitElement as
|
1
|
+
import{__decorate as t}from"tslib";import{LitElement as s,html as n}from"lit";import{property as i,state as e,customElement as o}from"lit/decorators.js";let a=class extends s{constructor(){super(...arguments),this.mode="foreColor",this.label="Text Color",this.value="#000000",this.palette=["#000000","#444444","#666666","#999999","#cccccc","#eeeeee","#ffffff","#d32f2f","#f44336","#ff9800","#ffeb3b","#4caf50","#2196f3","#3f51b5","#9c27b0","#03a9f4","#00bcd4","#009688","#8bc34a","#cddc39","#ffc107","#ff5722"],this.recentColors=[],this.pickCustom=()=>this.inputEl.click()}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.injectCss("\n nile-button.rte-color-trigger::part(base){\n width:32px; height:32px; padding:0px 6px;\n }\n\n .glyph-stack { display:grid; align-items:center; justify-items:center; line-height:1; }\n .glyph { font-size:14px; margin-bottom:2px; }\n .underline { width:18px; height:3px; border-radius:2px; }\n .swatch-box { width:18px; height:16px; border-radius:4px; border:1px solid rgba(0,0,0,0.35); }\n\n nile-popover::part(popover) {\n min-width: 225px;\n height: 250px;\n padding: 0px;\n gap: 0px;\n }\n\n .swatch-dropdown {\n height: 245px;\n width: 275px;\n padding: 12px;\n background: #fff;\n border-radius: 8px;\n box-sizing: border-box;\n overflow-y: auto;\n }\n\n .section { margin-bottom: 12px; }\n .title { font-size: 13px; font-weight: 600; margin-bottom: 8px; color:#111; }\n\n .swatches {\n display: grid;\n grid-template-columns: repeat(auto-fill, 24px);\n gap: 8px;\n }\n\n .swatch {\n width: 24px;\n height: 24px;\n border-radius: 50%;\n border: 1px solid rgba(0,0,0,0.25);\n cursor: pointer;\n position: relative;\n background-clip: content-box;\n }\n\n .swatch.add {\n display:flex;\n align-items:center;\n justify-content:center;\n font-weight:bold;\n font-size:16px;\n background:#fff;\n }\n\n .checkmark {\n position: absolute;\n top: 50%; left: 50%;\n transform: translate(-50%,-50%);\n font-size: 13px;\n color: white;\n text-shadow: 0 0 2px rgba(0,0,0,0.6);\n }\n "),this.inputEl=document.createElement("input"),this.inputEl.type="color",this.inputEl.style.position="absolute",this.inputEl.style.opacity="0",this.inputEl.style.pointerEvents="none",this.inputEl.value=this.value,this.appendChild(this.inputEl),this.inputEl.addEventListener("input",(()=>this.setColor(this.inputEl.value)))}injectCss(t){if(this.querySelector("style[data-rte-color-style]"))return;const s=document.createElement("style");s.setAttribute("data-rte-color-style","true"),s.textContent=t,this.insertBefore(s,this.firstChild)}setColor(t){this.value=t,this.recentColors=[t,...this.recentColors.filter((s=>s!==t))].slice(0,8),this.dispatchEvent(new CustomEvent("change",{detail:{mode:this.mode,value:t},bubbles:!0,composed:!0}))}render(){return n`
|
2
|
+
<nile-popover placement="bottom-start" distance="6" .arrow=${!1}>
|
3
|
+
<nile-button
|
4
|
+
slot="anchor"
|
5
|
+
variant="ghost"
|
6
|
+
size="small"
|
7
|
+
aria-label=${this.label}
|
8
|
+
class="rte-color-trigger"
|
9
|
+
>
|
10
|
+
${"backColor"===this.mode?n`<span class="swatch-box" style="background:${this.value}"></span>`:n`
|
11
|
+
<span class="glyph-stack">
|
12
|
+
<span class="glyph">A</span>
|
13
|
+
<span class="underline" style="background:${this.value}"></span>
|
14
|
+
</span>
|
15
|
+
`}
|
16
|
+
</nile-button>
|
17
|
+
|
18
|
+
<div part="base" class="swatch-dropdown">
|
19
|
+
<div class="section">
|
20
|
+
<div class="title">Default</div>
|
21
|
+
<div class="swatches">
|
22
|
+
${this.palette.map((t=>n`
|
23
|
+
<button class="swatch" style="background:${t}"
|
24
|
+
@click=${()=>this.setColor(t)}
|
25
|
+
title=${t}>
|
26
|
+
${this.value===t?n`<span class="checkmark">✓</span>`:""}
|
27
|
+
</button>
|
28
|
+
`))}
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
|
32
|
+
${this.recentColors.length>0?n`
|
33
|
+
<div class="section">
|
34
|
+
<div class="title">Recently Used</div>
|
35
|
+
<div class="swatches">
|
36
|
+
${this.recentColors.map((t=>n`
|
37
|
+
<button class="swatch" style="background:${t}"
|
38
|
+
@click=${()=>this.setColor(t)}
|
39
|
+
title=${t}></button>
|
40
|
+
`))}
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
`:""}
|
44
|
+
|
45
|
+
<div class="section">
|
46
|
+
<div class="title">Custom</div>
|
47
|
+
<div class="swatches">
|
48
|
+
<button class="swatch add" @click=${this.pickCustom}>+</button>
|
49
|
+
<nile-icon name="eyedropper"></nile-icon>
|
50
|
+
</div>
|
51
|
+
</div>
|
52
|
+
</div>
|
53
|
+
</nile-popover>
|
54
|
+
`}};t([i({type:String})],a.prototype,"mode",void 0),t([i({type:String})],a.prototype,"label",void 0),t([i({type:String})],a.prototype,"value",void 0),t([i({type:Array})],a.prototype,"palette",void 0),t([e()],a.prototype,"recentColors",void 0),a=t([o("nile-rte-color")],a);
|
@@ -0,0 +1,2 @@
|
|
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);}System.register(["tslib","lit","lit/decorators.js"],function(_export,_context){"use strict";var t,n,e,i,r,s,_templateObject,o;function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}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);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){n=_lit.LitElement;e=_lit.html;},function(_litDecoratorsJs){i=_litDecoratorsJs.property;r=_litDecoratorsJs.state;s=_litDecoratorsJs.customElement;}],execute:function execute(){o=/*#__PURE__*/function(_n){function o(){var _this;_classCallCheck(this,o);_this=_callSuper(this,o,arguments),_this.placeholder="https://",_this.linkValue="",_this.selectionRange=null;return _this;}_inherits(o,_n);return _createClass(o,[{key:"createRenderRoot",value:function createRenderRoot(){return this;}},{key:"connectedCallback",value:function connectedCallback(){_superPropGet(o,"connectedCallback",this,3)([]),this.injectCss("\n nile-rte-link nile-button.rte-link-trigger::part(base) {\n width: 32px;\n height: 32px;\n padding: 0;\n border: none;\n border-radius: 6px;\n }\n .link-popup {\n display: flex;\n gap: 6px;\n padding: 6px 8px;\n align-items: center;\n background: white;\n }\n .link-input {\n flex: 1;\n padding: 6px 8px;\n font-size: 14px;\n border: 1px solid #ccc;\n border-radius: 4px;\n }\n nile-popover.rte-link-popover::part(popover) {\n min-width: 250px;\n height: 44px;\n padding: 0px;\n gap: 0px;\n }\n ");}},{key:"injectCss",value:function injectCss(t){if(this.querySelector("style[data-rte-link-style]"))return;var n=document.createElement("style");n.setAttribute("data-rte-link-style","true"),n.textContent=t,this.insertBefore(n,this.firstChild);}},{key:"onOpen",value:function onOpen(){var _e,_this2=this;if(!this.editorEl)return;var t=document.getSelection();if(!t||0===t.rangeCount)return;this.selectionRange=t.getRangeAt(0).cloneRange();var n=t.anchorNode,e=null;for(;n&&n!==this.editorEl;){if(n instanceof HTMLAnchorElement){e=n;break;}n=n.parentNode;}this.linkValue=((_e=e)===null||_e===void 0?void 0:_e.href)||"",setTimeout(function(){var _this2$querySelector;(_this2$querySelector=_this2.querySelector(".link-input"))===null||_this2$querySelector===void 0||_this2$querySelector.focus();},0);}},{key:"onApply",value:function onApply(){if(!this.editorEl||!this.selectionRange)return;var t=this.linkValue.trim();if(!t)return;var n=document.getSelection();if(!n)return;n.removeAllRanges(),n.addRange(this.selectionRange);var e=this.selectionRange.startContainer,i=null;for(;e&&e!==this.editorEl;){if(e instanceof HTMLAnchorElement){i=e;break;}e=e.parentNode;}if(i)i.href=t;else{var _n2=document.createElement("a");if(_n2.href=t,this.selectionRange.collapsed)_n2.textContent=t,this.selectionRange.insertNode(_n2);else try{this.selectionRange.surroundContents(_n2);}catch(_unused){var _t=this.selectionRange.extractContents();_n2.appendChild(_t),this.selectionRange.insertNode(_n2);}}this.emit(t);var r=this.querySelector("nile-popover");r&&(r.isShow=!1);}},{key:"emit",value:function emit(t){this.dispatchEvent(new CustomEvent("link-changed",{detail:{href:t},bubbles:!0,composed:!0}));}},{key:"render",value:function render(){var _this3=this;return e(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <nile-popover placement=\"bottom-start\" class=\"rte-link-popover\" distance=\"10\" .arrow=",">\n <nile-button class=\"rte-link-trigger\" slot=\"anchor\" variant=\"tertiary\" size=\"small\" @click=",">\n <nile-icon name=\"link_2\" aria-label=\"Insert/Edit Link\"></nile-icon>\n </nile-button>\n\n <div class=\"link-popup\">\n <input\n class=\"link-input\"\n type=\"text\"\n placeholder=\"Type or paste link here\"\n .value=","\n @input=","\n @keydown=","\n />\n <nile-button @click=",">Apply</nile-button>\n </div>\n </nile-popover>\n "])),!1,function(){return _this3.onOpen();},this.linkValue,function(t){return _this3.linkValue=t.target.value;},function(t){if("Enter"===t.key&&_this3.onApply(),"Escape"===t.key){var _t2=_this3.querySelector("nile-popover");_t2&&(_t2.isShow=!1);}},function(){return _this3.onApply();});}}]);}(n);t([i({attribute:!1})],o.prototype,"editorEl",void 0),t([i({type:String})],o.prototype,"placeholder",void 0),t([r()],o.prototype,"linkValue",void 0),o=t([s("nile-rte-link")],o);}};});
|
2
|
+
//# sourceMappingURL=nile-rte-link.cjs.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"nile-rte-link.cjs.js","sources":["../../../src/nile-rich-text-editor/nile-rte-link.ts"],"sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\n\n@customElement('nile-rte-link')\nexport class NileRteLink extends LitElement {\n protected createRenderRoot() { return this; }\n\n @property({ attribute: false }) editorEl!: HTMLElement;\n @property({ type: String }) placeholder = 'https://';\n\n @state() private linkValue = '';\n private selectionRange: Range | null = null;\n\n connectedCallback() {\n super.connectedCallback();\n this.injectCss(`\n nile-rte-link nile-button.rte-link-trigger::part(base) {\n width: 32px;\n height: 32px;\n padding: 0;\n border: none;\n border-radius: 6px;\n }\n .link-popup {\n display: flex;\n gap: 6px;\n padding: 6px 8px;\n align-items: center;\n background: white;\n }\n .link-input {\n flex: 1;\n padding: 6px 8px;\n font-size: 14px;\n border: 1px solid #ccc;\n border-radius: 4px;\n }\n nile-popover.rte-link-popover::part(popover) {\n min-width: 250px;\n height: 44px;\n padding: 0px;\n gap: 0px;\n }\n `);\n }\n\n private injectCss(cssText: string) {\n if (this.querySelector('style[data-rte-link-style]')) return;\n const style = document.createElement('style');\n style.setAttribute('data-rte-link-style', 'true');\n style.textContent = cssText;\n this.insertBefore(style, this.firstChild);\n }\n\n private onOpen() {\n if (!this.editorEl) return;\n const sel = document.getSelection();\n if (!sel || sel.rangeCount === 0) return;\n\n this.selectionRange = sel.getRangeAt(0).cloneRange();\n\n // Pre-fill with existing href if selection inside <a>\n let n: Node | null = sel.anchorNode;\n let a: HTMLAnchorElement | null = null;\n while (n && n !== this.editorEl) {\n if (n instanceof HTMLAnchorElement) { a = n; break; }\n n = n.parentNode;\n }\n this.linkValue = a?.href || '';\n\n setTimeout(() => {\n this.querySelector<HTMLInputElement>('.link-input')?.focus();\n }, 0);\n }\n\n private onApply() {\n if (!this.editorEl || !this.selectionRange) return;\n const url = this.linkValue.trim();\n if (!url) return;\n\n const sel = document.getSelection();\n if (!sel) return;\n sel.removeAllRanges();\n sel.addRange(this.selectionRange);\n\n // Check for existing <a>\n let n: Node | null = this.selectionRange.startContainer;\n let a: HTMLAnchorElement | null = null;\n while (n && n !== this.editorEl) {\n if (n instanceof HTMLAnchorElement) { a = n; break; }\n n = n.parentNode;\n }\n\n if (a) {\n a.href = url;\n } else {\n const link = document.createElement('a');\n link.href = url;\n if (this.selectionRange.collapsed) {\n link.textContent = url;\n this.selectionRange.insertNode(link);\n } else {\n try {\n this.selectionRange.surroundContents(link);\n } catch {\n const frag = this.selectionRange.extractContents();\n link.appendChild(frag);\n this.selectionRange.insertNode(link);\n }\n }\n }\n\n this.emit(url);\n\n // Close the popover by toggling `open`\n const pop = this.querySelector('nile-popover');\n if (pop) (pop as any).isShow = false;\n }\n\n private emit(href: string) {\n this.dispatchEvent(new CustomEvent('link-changed', {\n detail: { href },\n bubbles: true,\n composed: true\n }));\n }\n\n render() {\n return html`\n <nile-popover placement=\"bottom-start\" class=\"rte-link-popover\" distance=\"10\" .arrow=${false}>\n <nile-button class=\"rte-link-trigger\" slot=\"anchor\" variant=\"tertiary\" size=\"small\" @click=${() => this.onOpen()}>\n <nile-icon name=\"link_2\" aria-label=\"Insert/Edit Link\"></nile-icon>\n </nile-button>\n\n <div class=\"link-popup\">\n <input\n class=\"link-input\"\n type=\"text\"\n placeholder=\"Type or paste link here\"\n .value=${this.linkValue}\n @input=${(e: any) => this.linkValue = e.target.value}\n @keydown=${(e: KeyboardEvent) => {\n if (e.key === 'Enter') this.onApply();\n if (e.key === 'Escape') {\n const pop = this.querySelector('nile-popover');\n if (pop) (pop as any).isShow = false;\n }\n }}\n />\n <nile-button @click=${() => this.onApply()}>Apply</nile-button>\n </div>\n </nile-popover>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-rte-link': NileRteLink;\n }\n}\n"],"names":["NileRteLink","o","constructor","this","placeholder","linkValue","selectionRange","_this","_inherits","_n","_createClass","key","value","createRenderRoot","connectedCallback","super","injectCss","cssText","querySelector","style","document","createElement","setAttribute","textContent","insertBefore","firstChild","onOpen","editorEl","sel","getSelection","rangeCount","getRangeAt","cloneRange","n","anchorNode","a","HTMLAnchorElement","parentNode","href","setTimeout","_this2$querySelector","focus","onApply","url","trim","removeAllRanges","addRange","startContainer","link","collapsed","insertNode","surroundContents","_unused","frag","extractContents","appendChild","emit","pop","isShow","dispatchEvent","CustomEvent","detail","bubbles","composed","render","html","_templateObject","_taggedTemplateLiteral","e","target","LitElement","__decorate","property","attribute","prototype","type","String","state","customElement"],"mappings":"8+GAIaA,CAAAA,uBAAAA,EAAAA,EAAN,SAAAC,EAAA,CAAA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,CAAAA,CAAA0E,SAAA,CAAA,WAAA,CAAA,IAAA,EANrB1E,CAAAA,CAAAA,CAAAA,CAAWuE,CAAA,CAAA,CADvBO,EAAc,eACF9E,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import{__decorate as t}from"tslib";import{LitElement as n,html as e}from"lit";import{property as i,state as r,customElement as s}from"lit/decorators.js";let o=class extends n{constructor(){super(...arguments),this.placeholder="https://",this.linkValue="",this.selectionRange=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.injectCss("\n nile-rte-link nile-button.rte-link-trigger::part(base) {\n width: 32px;\n height: 32px;\n padding: 0;\n border: none;\n border-radius: 6px;\n }\n .link-popup {\n display: flex;\n gap: 6px;\n padding: 6px 8px;\n align-items: center;\n background: white;\n }\n .link-input {\n flex: 1;\n padding: 6px 8px;\n font-size: 14px;\n border: 1px solid #ccc;\n border-radius: 4px;\n }\n nile-popover.rte-link-popover::part(popover) {\n min-width: 250px;\n height: 44px;\n padding: 0px;\n gap: 0px;\n }\n ")}injectCss(t){if(this.querySelector("style[data-rte-link-style]"))return;const n=document.createElement("style");n.setAttribute("data-rte-link-style","true"),n.textContent=t,this.insertBefore(n,this.firstChild)}onOpen(){if(!this.editorEl)return;const t=document.getSelection();if(!t||0===t.rangeCount)return;this.selectionRange=t.getRangeAt(0).cloneRange();let n=t.anchorNode,e=null;for(;n&&n!==this.editorEl;){if(n instanceof HTMLAnchorElement){e=n;break}n=n.parentNode}this.linkValue=e?.href||"",setTimeout((()=>{this.querySelector(".link-input")?.focus()}),0)}onApply(){if(!this.editorEl||!this.selectionRange)return;const t=this.linkValue.trim();if(!t)return;const n=document.getSelection();if(!n)return;n.removeAllRanges(),n.addRange(this.selectionRange);let e=this.selectionRange.startContainer,i=null;for(;e&&e!==this.editorEl;){if(e instanceof HTMLAnchorElement){i=e;break}e=e.parentNode}if(i)i.href=t;else{const n=document.createElement("a");if(n.href=t,this.selectionRange.collapsed)n.textContent=t,this.selectionRange.insertNode(n);else try{this.selectionRange.surroundContents(n)}catch{const t=this.selectionRange.extractContents();n.appendChild(t),this.selectionRange.insertNode(n)}}this.emit(t);const r=this.querySelector("nile-popover");r&&(r.isShow=!1)}emit(t){this.dispatchEvent(new CustomEvent("link-changed",{detail:{href:t},bubbles:!0,composed:!0}))}render(){return e`
|
2
|
+
<nile-popover placement="bottom-start" class="rte-link-popover" distance="10" .arrow=${!1}>
|
3
|
+
<nile-button class="rte-link-trigger" slot="anchor" variant="tertiary" size="small" @click=${()=>this.onOpen()}>
|
4
|
+
<nile-icon name="link_2" aria-label="Insert/Edit Link"></nile-icon>
|
5
|
+
</nile-button>
|
6
|
+
|
7
|
+
<div class="link-popup">
|
8
|
+
<input
|
9
|
+
class="link-input"
|
10
|
+
type="text"
|
11
|
+
placeholder="Type or paste link here"
|
12
|
+
.value=${this.linkValue}
|
13
|
+
@input=${t=>this.linkValue=t.target.value}
|
14
|
+
@keydown=${t=>{if("Enter"===t.key&&this.onApply(),"Escape"===t.key){const t=this.querySelector("nile-popover");t&&(t.isShow=!1)}}}
|
15
|
+
/>
|
16
|
+
<nile-button @click=${()=>this.onApply()}>Apply</nile-button>
|
17
|
+
</div>
|
18
|
+
</nile-popover>
|
19
|
+
`}};t([i({attribute:!1})],o.prototype,"editorEl",void 0),t([i({type:String})],o.prototype,"placeholder",void 0),t([r()],o.prototype,"linkValue",void 0),o=t([s("nile-rte-link")],o);
|
@@ -1,2 +1,2 @@
|
|
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);}System.register(["tslib","lit","lit/decorators.js"],function(_export,_context){"use strict";var t,e,n,i,l,
|
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);}System.register(["tslib","lit","lit/decorators.js"],function(_export,_context){"use strict";var t,e,n,i,r,l,_templateObject,_templateObject2,_templateObject3,_templateObject4,_templateObject5,_templateObject6,_templateObject7,s,o;function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}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);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}function a(t){return s.has(t);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){e=_lit.LitElement;n=_lit.html;},function(_litDecoratorsJs){i=_litDecoratorsJs.property;r=_litDecoratorsJs.state;l=_litDecoratorsJs.customElement;}],execute:function execute(){s=new Set(["p","h1","h2","h3","h4","h5","h6"]);o=/*#__PURE__*/function(_e){function o(){var _this;_classCallCheck(this,o);_this=_callSuper(this,o,arguments),_this.type="",_this.options="[]",_this.label="",_this.selectedValue="";return _this;}_inherits(o,_e);return _createClass(o,[{key:"createRenderRoot",value:function createRenderRoot(){return this;}},{key:"mapAlignIcon",value:function mapAlignIcon(t){return{left:"format_align_left",center:"format_align_middle",right:"format_align_right",justify:"format_align_justify"}[t]||"format_align_left";}},{key:"parsedOptions",get:function get(){var _this$optionsObj,_this2=this;var t=(_this$optionsObj=this.optionsObj)!==null&&_this$optionsObj!==void 0?_this$optionsObj:this.options;var e=function(){if(Array.isArray(t))return t;try{return JSON.parse(String(t));}catch(_unused){return[];}}().map(function(t){var _t$value,_ref,_t$label,_t$icon;var e=(_t$value=t===null||t===void 0?void 0:t.value)!==null&&_t$value!==void 0?_t$value:t;return{value:e,label:(_ref=(_t$label=t===null||t===void 0?void 0:t.label)!==null&&_t$label!==void 0?_t$label:t===null||t===void 0?void 0:t.value)!==null&&_ref!==void 0?_ref:t,icon:(_t$icon=t===null||t===void 0?void 0:t.icon)!==null&&_t$icon!==void 0?_t$icon:"align"===_this2.type?_this2.mapAlignIcon(String(e)):void 0};});if("heading"===this.type){e.length;e=e.filter(function(t){return a(t.value);}),e.length,this.selectedValue&&!a(this.selectedValue)&&(this.selectedValue="");}return e;}},{key:"ensureDefault",value:function ensureDefault(){if(!this.selectedValue){var _t=this.parsedOptions[0];_t&&(this.selectedValue=_t.value);}}},{key:"onSelect",value:function onSelect(t){"heading"!==this.type||a(t)?(this.selectedValue=t,this.dispatchEvent(new CustomEvent("change",{detail:t,bubbles:!0,composed:!0}))):console.warn("[nile-rte-select] Ignoring invalid heading value: ".concat(t));}},{key:"connectedCallback",value:function connectedCallback(){_superPropGet(o,"connectedCallback",this,3)([]),this.injectLocalStyles();}},{key:"injectLocalStyles",value:function injectLocalStyles(){if(this.querySelector("style[data-rte-select-style]"))return;var t=document.createElement("style");t.setAttribute("data-rte-select-style","true"),t.textContent="\n nile-menu.rte-align-menu::part(menu__items-wrapper) {\n display: flex;\n }\n nile-menu.rte-align-menu,\n nile-menu.rte-default-menu {\n margin-top: 0px;\n }\n nile-button.rte-align-trigger::part(base),\n nile-button.rte-default-trigger::part(base) {\n min-width: 32px;\n height: 32px;\n padding: 0px 6px;\n box-shadow: none;\n }\n nile-button.rte-align-trigger::part(base) {\n \n\n border: none;\n}\n ",this.insertBefore(t,this.firstChild);}},{key:"render",value:function render(){var _this3=this;var t=this.parsedOptions;this.ensureDefault();var e=t.find(function(t){return t.value===_this3.selectedValue;});if("align"===this.type){var _i=e!==null&&e!==void 0&&e.icon?n(_templateObject||(_templateObject=_taggedTemplateLiteral(["<nile-icon name=\"","\"></nile-icon>"])),e.icon):this.label||"Align";return n(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["\n <nile-dropdown class=\"rte-align-dd\">\n <nile-button slot=\"trigger\" variant=\"tertiary\" class=\"rte-align-trigger\">\n ","\n </nile-button>\n <nile-menu class=\"rte-align-menu\">\n ","\n </nile-menu>\n </nile-dropdown>\n "])),_i,t.map(function(t){return n(_templateObject3||(_templateObject3=_taggedTemplateLiteral(["\n <nile-menu-item\n class=\"rte-align-item\"\n ?active=","\n @click=",">\n <nile-icon name=\"","\"></nile-icon>\n </nile-menu-item>\n "])),t.value===_this3.selectedValue,function(){return _this3.onSelect(t.value);},t.icon);}));}if("font"===this.type){var _i2=(e===null||e===void 0?void 0:e.label)||this.label||"Font";return n(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["\n <nile-dropdown class=\"rte-default-dd\">\n <nile-button\n slot=\"trigger\"\n variant=\"tertiary\"\n class=\"rte-default-trigger\"\n style=\"font-family: ","\">\n "," <nile-icon name=\"arrowdown\"></nile-icon>\n </nile-button>\n <nile-menu class=\"rte-default-menu\">\n ","\n </nile-menu>\n </nile-dropdown>\n "])),(e===null||e===void 0?void 0:e.value)||"inherit",_i2,t.map(function(t){return n(_templateObject5||(_templateObject5=_taggedTemplateLiteral(["\n <nile-menu-item\n style=\"font-family: ","\"\n ?active=","\n @click=",">\n ","\n </nile-menu-item>\n "])),t.value,t.value===_this3.selectedValue,function(){return _this3.onSelect(t.value);},t.label);}));}var i=(e===null||e===void 0?void 0:e.label)||this.label||"Select";return n(_templateObject6||(_templateObject6=_taggedTemplateLiteral(["\n <nile-dropdown class=\"rte-default-dd\">\n <nile-button slot=\"trigger\" variant=\"tertiary\" class=\"rte-default-trigger\">\n "," <nile-icon name=\"arrowdown\"></nile-icon>\n </nile-button>\n <nile-menu class=\"rte-default-menu\">\n ","\n </nile-menu>\n </nile-dropdown>\n "])),i,t.map(function(t){return n(_templateObject7||(_templateObject7=_taggedTemplateLiteral(["\n <nile-menu-item\n ?active=","\n @click=",">\n ","\n </nile-menu-item>\n "])),t.value===_this3.selectedValue,function(){return _this3.onSelect(t.value);},t.label);}));}}]);}(e);t([i({type:String})],o.prototype,"type",void 0),t([i({type:String})],o.prototype,"options",void 0),t([i({attribute:!1})],o.prototype,"optionsObj",void 0),t([i({type:String})],o.prototype,"label",void 0),t([r()],o.prototype,"selectedValue",void 0),o=t([l("nile-rte-select")],o);}};});
|
2
2
|
//# sourceMappingURL=nile-rte-select.cjs.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-rte-select.cjs.js","sources":["../../../src/nile-rich-text-editor/nile-rte-select.ts"],"sourcesContent":[" // nile-rte-select.ts\n import { LitElement, html } from 'lit';\n import { customElement, property, state } from 'lit/decorators.js';\n\n type HeadingTag = 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n type GenericOption = { value: string; label?: string; icon?: string };\n type HeadingOption = { value: HeadingTag; label?: string; icon?: string };\n type NormalizedOption = { value: string; label: string; icon?: string };\n\n const HEADING_ALLOWLIST: ReadonlySet<HeadingTag> = new Set([\n 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'\n ]);\n\n function isHeadingTag(v: string): v is HeadingTag {\n return HEADING_ALLOWLIST.has(v as HeadingTag);\n }\n\n @customElement('nile-rte-select')\n export class NileRteSelect extends LitElement {\n protected createRenderRoot() { return this; }\n\n /** 'heading' | 'font' | 'align' */\n @property({ type: String }) type = '';\n\n /** JSON: [{ value, label?, icon? }, ...] (attribute-based; runtime-validated) */\n @property({ type: String }) options = '[]';\n\n /** Programmatic options (preferred for TS safety). */\n @property({ attribute: false })\n optionsObj?: Array<GenericOption | HeadingOption>;\n\n /** Fallback label for trigger (e.g., \"Align\") */\n @property({ type: String }) label = '';\n\n @state() private selectedValue = '';\n\n private mapAlignIcon(v: string) {\n const map: Record<string,string> = {\n left: 'format_align_left',\n center: 'format_align_middle',\n right: 'format_align_right',\n justify: 'format_align_justify'\n };\n return map[v] || 'align-left';\n }\n\n private get parsedOptions(): NormalizedOption[] {\n // Prefer programmatic options if present (gives TS compile-time checks)\n const source: unknown = this.optionsObj ?? this.options;\n\n const rawArray: any[] = (() => {\n if (Array.isArray(source)) return source;\n try { return JSON.parse(String(source)); } catch { return []; }\n })();\n\n // Normalize to consistent shape\n let items: NormalizedOption[] = rawArray.map((o: any) => {\n const value: string = o?.value ?? o;\n const label: string = o?.label ?? o?.value ?? o;\n const icon: string | undefined =\n o?.icon ?? (this.type === 'align' ? this.mapAlignIcon(String(value)) : undefined);\n return { value, label, icon };\n });\n\n // If type is heading, enforce allowlist (runtime validation)\n if (this.type === 'heading') {\n const before = items.length;\n items = items.filter(i => isHeadingTag(i.value));\n if (items.length !== before) {\n }\n // If current selection is invalid for heading, reset\n if (this.selectedValue && !isHeadingTag(this.selectedValue)) {\n this.selectedValue = '';\n }\n }\n\n return items;\n }\n\n private ensureDefault() {\n if (!this.selectedValue) {\n const first = this.parsedOptions[0];\n if (first) this.selectedValue = first.value;\n }\n }\n\n private onSelect(value: string) {\n if (this.type === 'heading' && !isHeadingTag(value)) {\n console.warn(`[nile-rte-select] Ignoring invalid heading value: ${value}`);\n return;\n }\n this.selectedValue = value;\n this.dispatchEvent(new CustomEvent('change', {\n detail: value, bubbles: true, composed: true\n }));\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.injectLocalStyles();\n }\n\n private injectLocalStyles() {\n if (this.querySelector('style[data-rte-select-style]')) return;\n\n const style = document.createElement('style');\n style.setAttribute('data-rte-select-style', 'true');\n style.textContent = `\n nile-menu.rte-align-menu::part(menu__items-wrapper) {\n display: flex;\n }\n nile-menu.rte-align-menu,\n nile-menu.rte-default-menu {\n margin-top: 0px;\n }\n nile-button.rte-align-trigger::part(base),\n nile-button.rte-default-trigger::part(base) {\n min-width: 32px;\n height: 32px;\n padding: 0px 6px;\n box-shadow: none;\n }\n `;\n this.insertBefore(style, this.firstChild);\n }\n\n render() {\n const opts = this.parsedOptions;\n this.ensureDefault();\n const current = opts.find(o => o.value === this.selectedValue);\n\n // ► Align: icon-only items + icon trigger\n if (this.type === 'align') {\n const trigger = current?.icon\n ? html`<nile-icon name=\"${current.icon}\"></nile-icon>`\n : (this.label || 'Align');\n\n return html`\n <nile-dropdown class=\"rte-align-dd\">\n <nile-button slot=\"trigger\" variant=\"tertiary\" class=\"rte-align-trigger\">\n ${trigger}\n </nile-button>\n <nile-menu class=\"rte-align-menu\">\n ${opts.map(o => html`\n <nile-menu-item\n class=\"rte-align-item\"\n ?active=${o.value === this.selectedValue}\n @click=${() => this.onSelect(o.value)}>\n <nile-icon name=\"${o.icon}\"></nile-icon>\n </nile-menu-item>\n `)}\n </nile-menu>\n </nile-dropdown>\n `;\n }\n\n // ► Font: show labels, preview fonts in items and trigger\n if (this.type === 'font') {\n const triggerText = current?.label || this.label || 'Font';\n return html`\n <nile-dropdown class=\"rte-default-dd\">\n <nile-button\n slot=\"trigger\"\n variant=\"tertiary\"\n class=\"rte-default-trigger\"\n style=\"font-family: ${current?.value || 'inherit'}\">\n ${triggerText} <nile-icon name=\"arrowdown\"></nile-icon>\n </nile-button>\n <nile-menu class=\"rte-default-menu\">\n ${opts.map(o => html`\n <nile-menu-item\n style=\"font-family: ${o.value}\"\n ?active=${o.value === this.selectedValue}\n @click=${() => this.onSelect(o.value)}>\n ${o.label}\n </nile-menu-item>\n `)}\n </nile-menu>\n </nile-dropdown>\n `;\n }\n\n // ► Default (e.g., heading): text items; heading values are validated already\n const triggerText = current?.label || this.label || 'Select';\n return html`\n <nile-dropdown class=\"rte-default-dd\">\n <nile-button slot=\"trigger\" variant=\"tertiary\" class=\"rte-default-trigger\">\n ${triggerText} <nile-icon name=\"arrowdown\"></nile-icon>\n </nile-button>\n <nile-menu class=\"rte-default-menu\">\n ${opts.map(o => html`\n <nile-menu-item\n ?active=${o.value === this.selectedValue}\n @click=${() => this.onSelect(o.value)}>\n ${o.label}\n </nile-menu-item>\n `)}\n </nile-menu>\n </nile-dropdown>\n `;\n }\n }\n\n declare global {\n interface HTMLElementTagNameMap {\n 'nile-rte-select': NileRteSelect;\n }\n }\n"],"names":["isHeadingTag","v","HEADING_ALLOWLIST","has","setters","_tslib","Set","NileRteSelect","o","constructor","this","type","options","label","selectedValue","_this","_inherits","_e","_createClass","key","value","createRenderRoot","mapAlignIcon","left","center","right","justify","get","parsedOptions","source","optionsObj","items","Array","isArray","JSON","parse","String","_unused","map","icon","undefined","length","filter","i","ensureDefault","first","onSelect","dispatchEvent","CustomEvent","detail","bubbles","composed","console","warn","connectedCallback","super","injectLocalStyles","querySelector","style","document","createElement","setAttribute","textContent","insertBefore","firstChild","render","opts","current","find","trigger","html","_templateObject","_taggedTemplateLiteral","_templateObject2","_templateObject3","triggerText","_templateObject4","_templateObject5","_templateObject6","_templateObject7","__decorate","LitElement","property","prototype","attribute","state","customElement"],"mappings":"i2GAaE,QAASA,CAAAA,CAAaC,CAAAA,CAAAA,CAAAA,CACpB,MAAOC,CAAAA,CAAAA,CAAkBC,GAAIF,CAAAA,CAAAA,CAC/B,EAGO,OAAAG,OAAA,WAAAC,MAAA,sNATDH,CAAAA,CAA6C,GAAII,CAAAA,GAAAA,CAAI,CACzD,GAAK,CAAA,IAAA,CAAM,IAAM,CAAA,IAAA,CAAM,IAAM,CAAA,IAAA,CAAM,IAGrC,CAAA,CAAA,CAKaC,4BAAN,SAAAC,EAAA,CAAAC,KAAAA,KAAAA,CAAAA,eAAAA,MAAAA,CAAAA,qCAIuBC,KAAAA,CAAIC,IAAAA,CAAG,EAGPD,CAAAA,KAAAA,CAAOE,OAAG,CAAA,IAAA,CAOVF,KAAAA,CAAKG,KAAAA,CAAG,EAEnBH,CAAAA,KAAAA,CAAaI,cAAG,EAuKlC,QAAAC,KAAA,EAtLWC,SAAA,CAAAR,CAAA,CAAAS,EAAA,SAAAC,YAAA,CAAAV,CAAA,GAAA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,CAAAA,CAAAA"}
|
1
|
+
{"version":3,"file":"nile-rte-select.cjs.js","sources":["../../../src/nile-rich-text-editor/nile-rte-select.ts"],"sourcesContent":["// nile-rte-select.ts\nimport { LitElement, html } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\n\ntype HeadingTag = 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\ntype GenericOption = { value: string; label?: string; icon?: string };\ntype HeadingOption = { value: HeadingTag; label?: string; icon?: string };\ntype NormalizedOption = { value: string; label: string; icon?: string };\n\nconst HEADING_ALLOWLIST: ReadonlySet<HeadingTag> = new Set([\n 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'\n]);\n\nfunction isHeadingTag(v: string): v is HeadingTag {\n return HEADING_ALLOWLIST.has(v as HeadingTag);\n}\n\n@customElement('nile-rte-select')\nexport class NileRteSelect extends LitElement {\n protected createRenderRoot() { return this; }\n\n /** 'heading' | 'font' | 'align' */\n @property({ type: String }) type = '';\n\n /** JSON: [{ value, label?, icon? }, ...] (attribute-based; runtime-validated) */\n @property({ type: String }) options = '[]';\n\n /** Programmatic options (preferred for TS safety). */\n @property({ attribute: false })\n optionsObj?: Array<GenericOption | HeadingOption>;\n\n /** Fallback label for trigger (e.g., \"Align\") */\n @property({ type: String }) label = '';\n\n @state() private selectedValue = '';\n\n private mapAlignIcon(v: string) {\n const map: Record<string,string> = {\n left: 'format_align_left',\n center: 'format_align_middle',\n right: 'format_align_right',\n justify: 'format_align_justify'\n };\n return map[v] || 'format_align_left';\n }\n\n private get parsedOptions(): NormalizedOption[] {\n // Prefer programmatic options if present (gives TS compile-time checks)\n const source: unknown = this.optionsObj ?? this.options;\n\n const rawArray: any[] = (() => {\n if (Array.isArray(source)) return source;\n try { return JSON.parse(String(source)); } catch { return []; }\n })();\n\n // Normalize to consistent shape\n let items: NormalizedOption[] = rawArray.map((o: any) => {\n const value: string = o?.value ?? o;\n const label: string = o?.label ?? o?.value ?? o;\n const icon: string | undefined =\n o?.icon ?? (this.type === 'align' ? this.mapAlignIcon(String(value)) : undefined);\n return { value, label, icon };\n });\n\n // If type is heading, enforce allowlist (runtime validation)\n if (this.type === 'heading') {\n const before = items.length;\n items = items.filter(i => isHeadingTag(i.value));\n if (items.length !== before) {\n }\n // If current selection is invalid for heading, reset\n if (this.selectedValue && !isHeadingTag(this.selectedValue)) {\n this.selectedValue = '';\n }\n }\n\n return items;\n }\n\n private ensureDefault() {\n if (!this.selectedValue) {\n const first = this.parsedOptions[0];\n if (first) this.selectedValue = first.value;\n }\n }\n\n private onSelect(value: string) {\n if (this.type === 'heading' && !isHeadingTag(value)) {\n console.warn(`[nile-rte-select] Ignoring invalid heading value: ${value}`);\n return;\n }\n this.selectedValue = value;\n this.dispatchEvent(new CustomEvent('change', {\n detail: value, bubbles: true, composed: true\n }));\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.injectLocalStyles();\n }\n\n private injectLocalStyles() {\n if (this.querySelector('style[data-rte-select-style]')) return;\n\n const style = document.createElement('style');\n style.setAttribute('data-rte-select-style', 'true');\n style.textContent = `\n nile-menu.rte-align-menu::part(menu__items-wrapper) {\n display: flex;\n }\n nile-menu.rte-align-menu,\n nile-menu.rte-default-menu {\n margin-top: 0px;\n }\n nile-button.rte-align-trigger::part(base),\n nile-button.rte-default-trigger::part(base) {\n min-width: 32px;\n height: 32px;\n padding: 0px 6px;\n box-shadow: none;\n }\n nile-button.rte-align-trigger::part(base) {\n \n\n border: none;\n}\n `;\n this.insertBefore(style, this.firstChild);\n }\n\n render() {\n const opts = this.parsedOptions;\n this.ensureDefault();\n const current = opts.find(o => o.value === this.selectedValue);\n\n // ► Align: icon-only items + icon trigger\n if (this.type === 'align') {\n const trigger = current?.icon\n ? html`<nile-icon name=\"${current.icon}\"></nile-icon>`\n : (this.label || 'Align');\n\n return html`\n <nile-dropdown class=\"rte-align-dd\">\n <nile-button slot=\"trigger\" variant=\"tertiary\" class=\"rte-align-trigger\">\n ${trigger}\n </nile-button>\n <nile-menu class=\"rte-align-menu\">\n ${opts.map(o => html`\n <nile-menu-item\n class=\"rte-align-item\"\n ?active=${o.value === this.selectedValue}\n @click=${() => this.onSelect(o.value)}>\n <nile-icon name=\"${o.icon}\"></nile-icon>\n </nile-menu-item>\n `)}\n </nile-menu>\n </nile-dropdown>\n `;\n }\n\n // ► Font: show labels, preview fonts in items and trigger\n if (this.type === 'font') {\n const triggerText = current?.label || this.label || 'Font';\n return html`\n <nile-dropdown class=\"rte-default-dd\">\n <nile-button\n slot=\"trigger\"\n variant=\"tertiary\"\n class=\"rte-default-trigger\"\n style=\"font-family: ${current?.value || 'inherit'}\">\n ${triggerText} <nile-icon name=\"arrowdown\"></nile-icon>\n </nile-button>\n <nile-menu class=\"rte-default-menu\">\n ${opts.map(o => html`\n <nile-menu-item\n style=\"font-family: ${o.value}\"\n ?active=${o.value === this.selectedValue}\n @click=${() => this.onSelect(o.value)}>\n ${o.label}\n </nile-menu-item>\n `)}\n </nile-menu>\n </nile-dropdown>\n `;\n }\n\n // ► Default (e.g., heading): text items; heading values are validated already\n const triggerText = current?.label || this.label || 'Select';\n return html`\n <nile-dropdown class=\"rte-default-dd\">\n <nile-button slot=\"trigger\" variant=\"tertiary\" class=\"rte-default-trigger\">\n ${triggerText} <nile-icon name=\"arrowdown\"></nile-icon>\n </nile-button>\n <nile-menu class=\"rte-default-menu\">\n ${opts.map(o => html`\n <nile-menu-item\n ?active=${o.value === this.selectedValue}\n @click=${() => this.onSelect(o.value)}>\n ${o.label}\n </nile-menu-item>\n `)}\n </nile-menu>\n </nile-dropdown>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-rte-select': NileRteSelect;\n }\n}\n"],"names":["isHeadingTag","v","HEADING_ALLOWLIST","has","setters","_tslib","Set","NileRteSelect","o","constructor","this","type","options","label","selectedValue","_this","_inherits","_e","_createClass","key","value","createRenderRoot","mapAlignIcon","left","center","right","justify","get","parsedOptions","source","optionsObj","items","Array","isArray","JSON","parse","String","_unused","map","icon","undefined","length","filter","i","ensureDefault","first","onSelect","dispatchEvent","CustomEvent","detail","bubbles","composed","console","warn","connectedCallback","super","injectLocalStyles","querySelector","style","document","createElement","setAttribute","textContent","insertBefore","firstChild","render","opts","current","find","trigger","html","_templateObject","_taggedTemplateLiteral","_templateObject2","_templateObject3","triggerText","_templateObject4","_templateObject5","_templateObject6","_templateObject7","__decorate","LitElement","property","prototype","attribute","state","customElement"],"mappings":"i2GAaA,QAASA,CAAAA,CAAaC,CAAAA,CAAAA,CAAAA,CACpB,MAAOC,CAAAA,CAAAA,CAAkBC,GAAIF,CAAAA,CAAAA,CAC/B,EAGO,OAAAG,OAAA,WAAAC,MAAA,sNATDH,CAAAA,CAA6C,GAAII,CAAAA,GAAAA,CAAI,CACzD,GAAK,CAAA,IAAA,CAAM,IAAM,CAAA,IAAA,CAAM,IAAM,CAAA,IAAA,CAAM,IAGrC,CAAA,CAAA,CAKaC,4BAAN,SAAAC,EAAA,CAAAC,KAAAA,KAAAA,CAAAA,eAAAA,MAAAA,CAAAA,qCAIuBC,KAAAA,CAAIC,IAAAA,CAAG,EAGPD,CAAAA,KAAAA,CAAOE,OAAG,CAAA,IAAA,CAOVF,KAAAA,CAAKG,KAAAA,CAAG,EAEnBH,CAAAA,KAAAA,CAAaI,cAAG,EA4KlC,QAAAC,KAAA,EA3LWC,SAAA,CAAAR,CAAA,CAAAS,EAAA,SAAAC,YAAA,CAAAV,CAAA,GAAAW,GAAA,oBAAAC,KAAA,UAAAC,gBAAAA,CAAAA,CAAAA,CAAqB,MAAOX,KAAO,EAiBrC,GAAAS,GAAA,gBAAAC,KAAA,UAAAE,YAAAA,CAAarB,CAAAA,CAAAA,CAOnB,MANmC,CACjCsB,IAAM,CAAA,mBAAA,CACNC,MAAQ,CAAA,qBAAA,CACRC,MAAO,oBACPC,CAAAA,OAAAA,CAAS,sBAEAzB,CAAAA,CAAAA,CAAAA,CAAAA,EAAM,mBAClB,EAED,GAAAkB,GAAA,iBAAA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