u2ui 1.0.0
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/.htaccess +7 -0
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/attr/behavior/README.md +25 -0
- package/attr/behavior/behavior.js +261 -0
- package/attr/behavior/manifest.json +43 -0
- package/attr/behavior/tests/minimal.html +19 -0
- package/attr/behavior/tests/test.html +98 -0
- package/attr/confirm/README.md +36 -0
- package/attr/confirm/confirm.js +90 -0
- package/attr/confirm/manifest.json +43 -0
- package/attr/confirm/tests/minimal.html +23 -0
- package/attr/confirm/tests/test.html +79 -0
- package/attr/draghandle/README.md +41 -0
- package/attr/draghandle/draghandle.js +42 -0
- package/attr/draghandle/tests/minimal.html +44 -0
- package/attr/focusgroup/README.md +49 -0
- package/attr/focusgroup/focusgroup.js +100 -0
- package/attr/focusgroup/manifest.json +38 -0
- package/attr/focusgroup/tests/minimal.html +27 -0
- package/attr/focusgroup/tests/test.html +154 -0
- package/attr/href/README.md +38 -0
- package/attr/href/href.js +42 -0
- package/attr/href/manifest.json +43 -0
- package/attr/href/tests/minimal.html +17 -0
- package/attr/href/tests/test.html +70 -0
- package/attr/intersect/README.md +42 -0
- package/attr/intersect/intersect.js +99 -0
- package/attr/intersect/manifest.json +57 -0
- package/attr/intersect/tests/minimal.html +30 -0
- package/attr/intersect/tests/test.html +64 -0
- package/attr/navigable/README.md +31 -0
- package/attr/navigable/TargetObserver.js +91 -0
- package/attr/navigable/U2TargetObserver.js +75 -0
- package/attr/navigable/manifest.json +42 -0
- package/attr/navigable/navigable.js +87 -0
- package/attr/navigable/tests/U1TargetObserver.html +56 -0
- package/attr/navigable/tests/minimal.html +17 -0
- package/attr/navigable/tests/targetObserver.html +106 -0
- package/attr/navigable/tests/test.html +84 -0
- package/attr/parallax/README.md +48 -0
- package/attr/parallax/parallax.js +119 -0
- package/attr/parallax/tests/minimal.html +25 -0
- package/attr/parallax/tests/performance.html +102 -0
- package/attr/parallax/tests/test.html +108 -0
- package/attr/skin/README.md +59 -0
- package/attr/skin/skin.css +51 -0
- package/attr/skin/tests/minimal.html +34 -0
- package/attr/skin/tests/test.html +96 -0
- package/class/badge/README.md +25 -0
- package/class/badge/badge.css +35 -0
- package/class/badge/tests/minimal.html +17 -0
- package/class/badge/tests/test.html +112 -0
- package/class/card1/README.md +45 -0
- package/class/card1/card1.css +30 -0
- package/class/card1/tests/minimal.html +33 -0
- package/class/card1/tests/test.html +78 -0
- package/class/flex/README.md +62 -0
- package/class/flex/flex.css +25 -0
- package/class/flex/tests/minimal.html +31 -0
- package/class/flex/tests/test.html +58 -0
- package/class/grid/README.md +52 -0
- package/class/grid/grid.css +40 -0
- package/class/grid/tests/minimal.html +34 -0
- package/class/grid/tests/test.html +78 -0
- package/class/input/README.md +49 -0
- package/class/input/input.css +33 -0
- package/class/input/tests/minimal.html +39 -0
- package/class/input/tests/test.html +29 -0
- package/class/reset/README.md +47 -0
- package/class/reset/reset.css +8 -0
- package/class/reset/tests/minimal.html +23 -0
- package/class/table/README.md +57 -0
- package/class/table/table.css +126 -0
- package/class/table/tests/minimal.html +40 -0
- package/class/table/tests/test.html +226 -0
- package/class/unstyle/README.md +32 -0
- package/class/unstyle/tests/minimal.html +22 -0
- package/class/unstyle/tests/test.html +32 -0
- package/class/unstyle/unstyle.css +12 -0
- package/class/width/README.md +48 -0
- package/class/width/tests/minimal.html +27 -0
- package/class/width/tests/test.html +101 -0
- package/class/width/width.css +22 -0
- package/css/base/README.md +25 -0
- package/css/base/base.css +127 -0
- package/css/base/beta.css +50 -0
- package/css/base/full.css +5 -0
- package/css/base/nomotion.css +9 -0
- package/css/base/print.css +36 -0
- package/css/base/tests/nomotion.html +89 -0
- package/css/base/tests/test.html +539 -0
- package/css/classes/README.md +17 -0
- package/css/classes/classes.css +78 -0
- package/css/classes/tests/test.html +63 -0
- package/css/classless/README.md +26 -0
- package/css/classless/aria.css +64 -0
- package/css/classless/classless.css +124 -0
- package/css/classless/full.css +11 -0
- package/css/classless/more.css +340 -0
- package/css/classless/simple.css +103 -0
- package/css/classless/snippeds/a/icons.css +12 -0
- package/css/classless/snippeds/experiments/conventions.css +41 -0
- package/css/classless/snippeds/hr/gradient.css +3 -0
- package/css/classless/snippeds/hr/section_sign.css +16 -0
- package/css/classless/snippeds/hr/tests.html +50 -0
- package/css/classless/tests/aria.html +101 -0
- package/css/classless/tests/foreign/classless-almond.css.html +445 -0
- package/css/classless/tests/foreign/classless-classless.css.html +831 -0
- package/css/classless/tests/foreign/classless-mvp.html +415 -0
- package/css/classless/tests/foreign/classless.sakura.html +224 -0
- package/css/classless/tests/foreign/stylestage.dev.html +304 -0
- package/css/classless/tests/foreign/test-homogenizer.html +433 -0
- package/css/classless/tests/foreign/test-html5-elements-tester.html +956 -0
- package/css/classless/tests/foreign/test-opinionated_css.html +148 -0
- package/css/classless/tests/list-bullet.html +110 -0
- package/css/classless/tests/more.html +246 -0
- package/css/classless/tests/oklch.experiments.html +280 -0
- package/css/classless/tests/test.html +106 -0
- package/css/classless/tests/variables.html +109 -0
- package/css/classless/variables.css +99 -0
- package/css/norm/README.md +37 -0
- package/css/norm/beta.css +40 -0
- package/css/norm/norm.css +98 -0
- package/css/norm/oldies.css +60 -0
- package/css/norm/tests/test.html +434 -0
- package/css/norm/tests/test.js +103 -0
- package/el/accordion/README.md +59 -0
- package/el/accordion/accordion.css +7 -0
- package/el/accordion/accordion.js +258 -0
- package/el/accordion/manifest.json +57 -0
- package/el/accordion/tests/minimal.html +44 -0
- package/el/accordion/tests/test.html +168 -0
- package/el/alert/README.md +67 -0
- package/el/alert/alert copy.js +224 -0
- package/el/alert/alert.css +73 -0
- package/el/alert/alert.js +187 -0
- package/el/alert/manifest.json +77 -0
- package/el/alert/tests/minimal.html +36 -0
- package/el/alert/tests/test.html +105 -0
- package/el/buttongroup/README.md +36 -0
- package/el/buttongroup/buttongroup.css +30 -0
- package/el/buttongroup/buttongroup.js +56 -0
- package/el/buttongroup/tests/minimal.html +31 -0
- package/el/buttongroup/tests/test.html +83 -0
- package/el/bytes/README.md +41 -0
- package/el/bytes/bytes.css +6 -0
- package/el/bytes/bytes.js +97 -0
- package/el/bytes/manifest.json +95 -0
- package/el/bytes/tests/minimal.html +19 -0
- package/el/bytes/tests/test.html +117 -0
- package/el/carousel/README.md +52 -0
- package/el/carousel/carousel.css +46 -0
- package/el/carousel/carousel.js +371 -0
- package/el/carousel/manifest.json +58 -0
- package/el/carousel/tests/experiments.html +77 -0
- package/el/carousel/tests/minimal.html +31 -0
- package/el/carousel/tests/nested.html +54 -0
- package/el/carousel/tests/test.html +136 -0
- package/el/carousel-nav/README.md +40 -0
- package/el/carousel-nav/carousel-nav.js +74 -0
- package/el/carousel-nav/tests/minimal.html +32 -0
- package/el/carousel-nav/tests/test.html +59 -0
- package/el/code/README.md +68 -0
- package/el/code/code.css +46 -0
- package/el/code/code.js +289 -0
- package/el/code/manifest.json +66 -0
- package/el/code/tests/minimal.html +35 -0
- package/el/code/tests/test.html +162 -0
- package/el/copy/README.md +35 -0
- package/el/copy/copy.css +3 -0
- package/el/copy/copy.js +118 -0
- package/el/copy/manifest.json +49 -0
- package/el/copy/tests/minimal.html +21 -0
- package/el/copy/tests/test.html +75 -0
- package/el/counter/README.md +47 -0
- package/el/counter/counter.css +8 -0
- package/el/counter/counter.js +95 -0
- package/el/counter/manifest.json +59 -0
- package/el/counter/tests/minimal.html +27 -0
- package/el/counter/tests/test.html +106 -0
- package/el/ico/README.md +162 -0
- package/el/ico/font/Font Awesome.css +22 -0
- package/el/ico/font/LigatureSymbols.css +7 -0
- package/el/ico/font/Material Icons.css +6 -0
- package/el/ico/font/RemixFilled.css +8 -0
- package/el/ico/font/RemixOutlined.css +8 -0
- package/el/ico/font/old/anicons.css +31 -0
- package/el/ico/font/old/devicons.css +210 -0
- package/el/ico/font/old/material.all.css +36 -0
- package/el/ico/font/old/remix.css +15 -0
- package/el/ico/font/old/utf8.css +54 -0
- package/el/ico/ico.css +111 -0
- package/el/ico/ico.js +189 -0
- package/el/ico/manifest.json +86 -0
- package/el/ico/tests/combinations.html +86 -0
- package/el/ico/tests/emojis.html +213 -0
- package/el/ico/tests/fonts.html +110 -0
- package/el/ico/tests/ico-directory.html +254 -0
- package/el/ico/tests/minimal.html +46 -0
- package/el/ico/tests/test.html +210 -0
- package/el/ico/tests/util-multi.svg +6 -0
- package/el/ico/tests/util.css +2 -0
- package/el/ico/tests/util.js +110 -0
- package/el/input/README.md +39 -0
- package/el/input/input.css +35 -0
- package/el/input/input.js +331 -0
- package/el/input/tests/formParticipation.html +113 -0
- package/el/input/tests/minimal.html +33 -0
- package/el/input/tests/test.html +258 -0
- package/el/masonry/README.md +51 -0
- package/el/masonry/manifest.json +60 -0
- package/el/masonry/masonry.css +27 -0
- package/el/masonry/masonry.js +92 -0
- package/el/masonry/tests/minimal.html +39 -0
- package/el/masonry/tests/test.html +42 -0
- package/el/number/README.md +47 -0
- package/el/number/manifest.json +121 -0
- package/el/number/number.css +6 -0
- package/el/number/number.js +67 -0
- package/el/number/tests/minimal.html +25 -0
- package/el/number/tests/test.html +138 -0
- package/el/out/README.md +32 -0
- package/el/out/manifest.json +38 -0
- package/el/out/out.css +2 -0
- package/el/out/out.js +59 -0
- package/el/out/tests/minimal.html +25 -0
- package/el/out/tests/test.html +37 -0
- package/el/parallax-bg/README.md +36 -0
- package/el/parallax-bg/parallax-bg.css +13 -0
- package/el/parallax-bg/parallax-bg.js +186 -0
- package/el/parallax-bg/tests/bg.jpg +0 -0
- package/el/parallax-bg/tests/bg1.jpg +0 -0
- package/el/parallax-bg/tests/bg2.jpg +0 -0
- package/el/parallax-bg/tests/demo.html +88 -0
- package/el/parallax-bg/tests/minimal.html +30 -0
- package/el/parallax-bg/tests/test.html +64 -0
- package/el/parallax-bg/tests/visible.html +90 -0
- package/el/qrcode/README.md +38 -0
- package/el/qrcode/manifest.json +43 -0
- package/el/qrcode/package.json +22 -0
- package/el/qrcode/qrcode.css +13 -0
- package/el/qrcode/qrcode.js +46 -0
- package/el/qrcode/tests/minimal.html +26 -0
- package/el/qrcode/tests/test.html +31 -0
- package/el/rating/README.md +45 -0
- package/el/rating/manifest.json +65 -0
- package/el/rating/rating.css +11 -0
- package/el/rating/rating.js +139 -0
- package/el/rating/tests/minimal.html +26 -0
- package/el/rating/tests/tests.html +77 -0
- package/el/rte/README.md +37 -0
- package/el/rte/rte.css +9 -0
- package/el/rte/rte.js +56 -0
- package/el/rte/tests/minimal.html +25 -0
- package/el/rte/tests/test.html +37 -0
- package/el/skeleton/README.md +30 -0
- package/el/skeleton/manifest.json +51 -0
- package/el/skeleton/skeleton.css +61 -0
- package/el/skeleton/skeleton.js +72 -0
- package/el/skeleton/tests/minimal.html +22 -0
- package/el/skeleton/tests/test.html +22 -0
- package/el/splitbutton/README.md +39 -0
- package/el/splitbutton/splitbutton.css +48 -0
- package/el/splitbutton/splitbutton.js +26 -0
- package/el/splitbutton/tests/minimal.html +30 -0
- package/el/splitbutton/tests/test.html +68 -0
- package/el/splitpanel/README.md +39 -0
- package/el/splitpanel/manifest.json +49 -0
- package/el/splitpanel/splitpanel.css +17 -0
- package/el/splitpanel/splitpanel.js +116 -0
- package/el/splitpanel/tests/minimal.html +31 -0
- package/el/splitpanel/tests/tests.html +121 -0
- package/el/table/README.md +68 -0
- package/el/table/manifest.json +43 -0
- package/el/table/table.css +59 -0
- package/el/table/table.js +194 -0
- package/el/table/tests/minimal.html +38 -0
- package/el/table/tests/test.html +108 -0
- package/el/tabs/README.md +50 -0
- package/el/tabs/manifest.json +59 -0
- package/el/tabs/tabs.css +23 -0
- package/el/tabs/tabs.js +210 -0
- package/el/tabs/tests/minimal.html +35 -0
- package/el/tabs/tests/test.html +180 -0
- package/el/textfit/README.md +34 -0
- package/el/textfit/manifest.json +45 -0
- package/el/textfit/tests/minimal.html +25 -0
- package/el/textfit/tests/test.html +26 -0
- package/el/textfit/textfit.css +6 -0
- package/el/textfit/textfit.js +80 -0
- package/el/time/README.md +72 -0
- package/el/time/manifest.json +118 -0
- package/el/time/tests/minimal.html +19 -0
- package/el/time/tests/test.html +160 -0
- package/el/time/time copy.js +141 -0
- package/el/time/time.js +168 -0
- package/el/time/time.old.uhtml.js +129 -0
- package/el/tooltip/README.md +48 -0
- package/el/tooltip/manifest.json +69 -0
- package/el/tooltip/tests/minimal.html +25 -0
- package/el/tooltip/tests/test.html +178 -0
- package/el/tooltip/tooltip.css +97 -0
- package/el/tooltip/tooltip.js +82 -0
- package/el/tree1/README.md +111 -0
- package/el/tree1/manifest.json +78 -0
- package/el/tree1/tests/animated.html +134 -0
- package/el/tree1/tests/custom.html +51 -0
- package/el/tree1/tests/minimal.html +44 -0
- package/el/tree1/tests/test.html +260 -0
- package/el/tree1/tree1.css +26 -0
- package/el/tree1/tree1.js +265 -0
- package/el/typewriter/README.md +62 -0
- package/el/typewriter/manifest.json +66 -0
- package/el/typewriter/tests/minimal.html +25 -0
- package/el/typewriter/tests/test.html +78 -0
- package/el/typewriter/typewriter.css +6 -0
- package/el/typewriter/typewriter.js +166 -0
- package/el/typewriter/typewriter.mp3 +0 -0
- package/js/Placer/Placer.js +156 -0
- package/js/Placer/README.md +62 -0
- package/js/Placer/tests/minimal.html +34 -0
- package/js/Placer/tests/test.html +49 -0
- package/js/PointerObserver/PointerObserver.js +130 -0
- package/js/PointerObserver/README.md +34 -0
- package/js/PointerObserver/tests/minimal.html +29 -0
- package/js/PointerObserver/tests/test.html +35 -0
- package/js/SelectorObserver/README.md +47 -0
- package/js/SelectorObserver/SelectorObserver.js +201 -0
- package/js/SelectorObserver/tests/minimal.html +21 -0
- package/js/SelectorObserver/tests/test.html +57 -0
- package/js/SelectorObserver/tests/tests.html +161 -0
- package/js/contextmenu/README.md +93 -0
- package/js/contextmenu/contextmenu.js +336 -0
- package/js/contextmenu/tests/minimal.html +44 -0
- package/js/contextmenu/tests/test.html +131 -0
- package/js/dialog/README.md +49 -0
- package/js/dialog/dialog.js +261 -0
- package/js/dialog/notification.mp3 +0 -0
- package/js/dialog/tests/minimal.html +29 -0
- package/js/dialog/tests/notification.mp3 +0 -0
- package/js/dialog/tests/test.html +135 -0
- package/js/rte/README.md +44 -0
- package/js/rte/old/NodeCleaner.js +315 -0
- package/js/rte/old/Rte/Rte.mjs +316 -0
- package/js/rte/old/Rte/Rte.ui.items.mjs +543 -0
- package/js/rte/old/Rte/Rte.ui.mjs +154 -0
- package/js/rte/old/Rte/crossbrowser.mjs +323 -0
- package/js/rte/old/Rte/font/tinymce.svg +98 -0
- package/js/rte/old/Rte/font/tinymce.woff +0 -0
- package/js/rte/old/Rte/helpers.mjs +159 -0
- package/js/rte/old/Rte/htmlparser.mjs +178 -0
- package/js/rte/old/Rte/index.mjs +5 -0
- package/js/rte/old/Rte/main.css +189 -0
- package/js/rte/old/old.rte.js +132 -0
- package/js/rte/old/range-selection.old.js +394 -0
- package/js/rte/rte.js +7 -0
- package/js/rte/src/behavior.js +228 -0
- package/js/rte/src/events.js +73 -0
- package/js/rte/src/fixes.js +251 -0
- package/js/rte/src/range.js +472 -0
- package/js/rte/src/rte.js +72 -0
- package/js/rte/src/ui/items/ai.js +167 -0
- package/js/rte/src/ui/items/code.js +93 -0
- package/js/rte/src/ui/items/undo.js +183 -0
- package/js/rte/src/ui.items.js +571 -0
- package/js/rte/src/ui.js +269 -0
- package/js/rte/src/util/htmlparser.js +178 -0
- package/js/rte/src/util/indentHtml.js +48 -0
- package/js/rte/tests/ai.html +81 -0
- package/js/rte/tests/behavior.html +88 -0
- package/js/rte/tests/events.html +69 -0
- package/js/rte/tests/fixes.html +95 -0
- package/js/rte/tests/minimal.html +34 -0
- package/js/rte/tests/notes.md +6 -0
- package/js/rte/tests/range.html +167 -0
- package/js/rte/tests/selection-explorer.html +222 -0
- package/js/rte/tests/test.html +92 -0
- package/js/shortcut/README.md +33 -0
- package/js/shortcut/shortcut.js +89 -0
- package/js/shortcut/tests/minimal.html +23 -0
- package/js/shortcut/tests/test.html +68 -0
- package/package.json +12 -0
- package/u2/README.md +4 -0
- package/u2/auto.js +161 -0
- package/u2/auto.ui.js +85 -0
- package/u2/experiments/Waiter/test.html +132 -0
- package/u2/experiments/getElementByIdPromise/test.html +76 -0
- package/u2/experiments/patchInputValue.html +124 -0
- package/u2/experiments/radiobutton/test.html +75 -0
- package/u2/experiments/tests/test.html +223 -0
- package/u2/experiments/u1-responsive/responsive.js +62 -0
- package/u2/experiments/u1-responsive/test.html +65 -0
- package/u2/experiments/u2Element.js +139 -0
- package/u2/experiments/u2Element.test.html +47 -0
- package/u2/old-stuff/IterableWeakMap/mod.js +70 -0
- package/u2/old-stuff/css/onStyleSheet/mod.js +114 -0
- package/u2/old-stuff/css/onStyleSheet/monkeypatches.js +28 -0
- package/u2/old-stuff/css/onStyleSheet/test/include.css +19 -0
- package/u2/old-stuff/css/onStyleSheet/test/style-has-include.css +6 -0
- package/u2/old-stuff/css/onStyleSheet/test/style-no-include.css +3 -0
- package/u2/old-stuff/css/onStyleSheet/test/test.html +48 -0
- package/u2/old-stuff/css/parser/mod.js +182 -0
- package/u2/old-stuff/css/parser/parser_old/mod.js +128 -0
- package/u2/old-stuff/css/parser/parser_old/test.html +43 -0
- package/u2/old-stuff/css/parser/parser_old/util.js +22 -0
- package/u2/old-stuff/css/parser/style.html +52 -0
- package/u2/old-stuff/css/parser/test.html +38 -0
- package/u2/old-stuff/el/ai-texter/README.md +23 -0
- package/u2/old-stuff/el/ai-texter/ai-texter.css +12 -0
- package/u2/old-stuff/el/ai-texter/ai-texter.js +153 -0
- package/u2/old-stuff/el/ai-texter/tests/minimal.html +47 -0
- package/u2/old-stuff/el/ai-texter/tests/test.html +71 -0
- package/u2/old-stuff/init.js +38 -0
- package/u2/old-stuff/markHashLinks.js +51 -0
- package/u2/old-stuff/onElement/mod.js +73 -0
- package/u2/old-stuff/test-helpers/mod.js +36 -0
- package/u2/old-stuff/test-helpers/test.html +4 -0
- package/u2/old-stuff/tests/init.js.html +51 -0
- package/u2/old-stuff/viewport.js +64 -0
- package/u2/projects.json +468 -0
- package/u2/tests/boilerplate.html +46 -0
- package/u2/tests/kacheln.html +245 -0
- package/u2/tests/showcase.html +270 -0
- package/u2/tests/showcase2.html +157 -0
- package/u2/tests/test-init.js +35 -0
- package/u2/tests/test.html +355 -0
- package/u2/tools/baseElement.js +95 -0
- package/u2/tools/baseElement.test.html +119 -0
- package/u2/tools/ce-inspector.js +308 -0
- package/u2/tools/ce-inspector.test.html +66 -0
- package/u2/tools/ce-manfest-from-element.js +207 -0
- package/u2/tools/dev-iframe.js +213 -0
- package/u2/tools/dev-iframe.test.html +75 -0
- package/u2/tools/eventsExplorer.js +101 -0
- package/u2/tools/logo/u1.svg +9 -0
- package/u2/tools/logo/u1ui.svg +6 -0
- package/u2/tools/update.repos.json.js +234 -0
- package/u2/u2.js +14 -0
- package/u2/utils.js +59 -0
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import {$range} from './range.js';
|
|
4
|
+
import * as state from './events.js';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
let x = my.setItem('Bold',
|
|
8
|
+
{
|
|
9
|
+
shortcut:'l'
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
x.addEventListener('mousedown', function() {
|
|
13
|
+
Rte.modifySelection(function(els) {
|
|
14
|
+
let first = $(els[1]||els[0]);
|
|
15
|
+
let act = first.hasClass('SmallText') ? 'removeClass' : 'addClass';
|
|
16
|
+
for (let i = els.length, el; el = els[--i];) {
|
|
17
|
+
$(el)[act]('SmallText');
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
let active = null;
|
|
24
|
+
addEventListener('u2-rte-activate', function(e) {
|
|
25
|
+
active = e.target;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const blocklessElements = {
|
|
29
|
+
'P':1,
|
|
30
|
+
'H1':1,
|
|
31
|
+
'H2':1,
|
|
32
|
+
'H3':1,
|
|
33
|
+
'H4':1,
|
|
34
|
+
'H5':1,
|
|
35
|
+
'H6':1,
|
|
36
|
+
'SPAN':1,
|
|
37
|
+
'BUTTON':1,
|
|
38
|
+
'B':1,
|
|
39
|
+
'I':1,
|
|
40
|
+
'STRONG':1,
|
|
41
|
+
'LABEL':1,
|
|
42
|
+
'A':1,
|
|
43
|
+
'BUTTON':1,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const lang = {
|
|
47
|
+
'Bold':{
|
|
48
|
+
de: 'Fett',
|
|
49
|
+
en: 'Bold',
|
|
50
|
+
fr: 'Gras',
|
|
51
|
+
},
|
|
52
|
+
'Italic':{
|
|
53
|
+
de: 'Kursiv',
|
|
54
|
+
en: 'Italic',
|
|
55
|
+
fr: 'Italique',
|
|
56
|
+
},
|
|
57
|
+
'Insertunorderedlist':{
|
|
58
|
+
de: 'Liste',
|
|
59
|
+
en: 'List',
|
|
60
|
+
fr: 'Liste',
|
|
61
|
+
},
|
|
62
|
+
'Insertorderedlist':{
|
|
63
|
+
de: 'Nummerierte Liste',
|
|
64
|
+
en: 'Numbered List',
|
|
65
|
+
fr: 'Liste numérotée',
|
|
66
|
+
},
|
|
67
|
+
'Underlined':{
|
|
68
|
+
de: 'Unterstrichen',
|
|
69
|
+
en: 'Underlined',
|
|
70
|
+
fr: 'Souligné',
|
|
71
|
+
},
|
|
72
|
+
'Hr':{
|
|
73
|
+
de: 'Horizontale Linie',
|
|
74
|
+
en: 'Horizontal Rule',
|
|
75
|
+
fr: 'Ligne horizontale',
|
|
76
|
+
},
|
|
77
|
+
'Strikethrough':{
|
|
78
|
+
de: 'Durchgestrichen',
|
|
79
|
+
en: 'Strikethrough',
|
|
80
|
+
fr: 'Barré',
|
|
81
|
+
},
|
|
82
|
+
'Format':{
|
|
83
|
+
de: 'Format',
|
|
84
|
+
en: 'Format',
|
|
85
|
+
fr: 'Format',
|
|
86
|
+
},
|
|
87
|
+
'Style':{
|
|
88
|
+
de: 'Stil',
|
|
89
|
+
en: 'Style',
|
|
90
|
+
fr: 'Style',
|
|
91
|
+
},
|
|
92
|
+
'Removeformat':{
|
|
93
|
+
de: 'Formatierungen entfernen',
|
|
94
|
+
en: 'Remove formatting',
|
|
95
|
+
fr: 'Supprimer le formatage',
|
|
96
|
+
},
|
|
97
|
+
'Table':{
|
|
98
|
+
de: 'Tabelle einfügen',
|
|
99
|
+
en: 'Insert table',
|
|
100
|
+
fr: 'Insérer un tableau',
|
|
101
|
+
},
|
|
102
|
+
'Link':{
|
|
103
|
+
de: 'Link',
|
|
104
|
+
en: 'Link',
|
|
105
|
+
fr: 'Lien',
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
Rte.ui.setItem('Bold', {cmd:'bold', shortcut:'b', xenable:':not(img)', labels:lang.Bold});
|
|
110
|
+
Rte.ui.setItem('Italic', {cmd:'italic', shortcut:'i', xenable:':not(img)', labels:lang.Italic});
|
|
111
|
+
Rte.ui.setItem('Underlined', {cmd:'underline', shortcut:'u', xenable:':not(img)', labels:lang.Underlined});
|
|
112
|
+
Rte.ui.setItem('Strikethrough', {cmd:'strikethrough', xenable:':not(img)', labels:lang.Strikethrough});
|
|
113
|
+
Rte.ui.setItem('Insertunorderedlist', {cmd:'insertunorderedlist',shortcut:'8', icon:'format-list-bulleted', enable(){ return !blocklessElements[active.tagName]; }, labels:lang.Insertunorderedlist});
|
|
114
|
+
Rte.ui.setItem('Insertorderedlist', {cmd:'insertorderedlist',shortcut:'9', icon:'format-list-numbered', enable(){ return !blocklessElements[active.tagName]; } , labels:lang.Insertorderedlist});
|
|
115
|
+
//Rte.ui.setItem('Undo', {cmd:'undo', check:false, icon:'undo'});
|
|
116
|
+
//Rte.ui.setItem('Redo', {cmd:'redo', check:false, icon:'redo'});
|
|
117
|
+
Rte.ui.setItem('Hr', {cmd:'inserthorizontalrule', check:false, icon:'horizontal-rule', enable(){ return !blocklessElements[active.tagName]; }, labels:lang.Hr});
|
|
118
|
+
|
|
119
|
+
import('./ui/items/undo.js');
|
|
120
|
+
import('./ui/items/code.js');
|
|
121
|
+
import('./ui/items/ai.js');
|
|
122
|
+
|
|
123
|
+
/* Headings */
|
|
124
|
+
{
|
|
125
|
+
const lang = document.documentElement.getAttribute('lang') || navigator.language.substring(0,2) || 'en';
|
|
126
|
+
const formatTrans = {
|
|
127
|
+
p: {de:'Absatz', en:'Paragraph', fr:'Paragraphe'},
|
|
128
|
+
h1: {de:'Überschrift 1', en:'Heading 1', fr:'Titre 1'},
|
|
129
|
+
h2: {de:'Überschrift 2', en:'Heading 2', fr:'Titre 2'},
|
|
130
|
+
h3: {de:'Überschrift 3', en:'Heading 3', fr:'Titre 3'},
|
|
131
|
+
h4: {de:'Überschrift 4', en:'Heading 4', fr:'Titre 4'},
|
|
132
|
+
h5: {de:'Überschrift 5', en:'Heading 5', fr:'Titre 5'},
|
|
133
|
+
h6: {de:'Überschrift 6', en:'Heading 6', fr:'Titre 6'},
|
|
134
|
+
blockquote: {de:'Zitat', en:'Blockquote', fr:'Citation'},
|
|
135
|
+
};
|
|
136
|
+
let opts = Rte.ui.setSelect('Format',{
|
|
137
|
+
click(e) {
|
|
138
|
+
const tag = e.target.getAttribute('value');
|
|
139
|
+
tag && document.execCommand('formatblock',false,tag);
|
|
140
|
+
},
|
|
141
|
+
check() {
|
|
142
|
+
const stat = document.queryCommandValue('formatblock');
|
|
143
|
+
for (const el of opts.children) {
|
|
144
|
+
el.className = el.tagName.toLowerCase()===stat ? '-selected' : '';
|
|
145
|
+
}
|
|
146
|
+
const show = formatTrans[stat]?.[lang] || formatTrans[stat]?.en || 'Format';
|
|
147
|
+
opts.previousElementSibling.innerHTML = state.element ? show : 'Format';
|
|
148
|
+
},
|
|
149
|
+
enable(e) {
|
|
150
|
+
return !blocklessElements[active.tagName];
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
opts.innerHTML = Object.entries(formatTrans).map(([tag, trans]) => `<${tag} value=${tag}>${trans[lang]??trans.en}</${tag}>`).join('');
|
|
154
|
+
}
|
|
155
|
+
/* CSS classes */
|
|
156
|
+
// {
|
|
157
|
+
// function useClass(cl) { return cl.match(/^[A-Z]/); };
|
|
158
|
+
// let hasClasses; /* check if this-handle is used */
|
|
159
|
+
// let check = function(el) {
|
|
160
|
+
// let classes = getPossibleClasses(el);
|
|
161
|
+
// for (let cl of Object.keys(classes)) {
|
|
162
|
+
// hasClasses = hasClasses || useClass(cl);
|
|
163
|
+
// }
|
|
164
|
+
// sopts.parentElement.style.display = hasClasses ? '' : 'none';
|
|
165
|
+
// }.c1Debounce(150);
|
|
166
|
+
|
|
167
|
+
// let sopts = Rte.ui.setSelect('Style', {
|
|
168
|
+
// check() {
|
|
169
|
+
// check();
|
|
170
|
+
// let classes = state.element && state.element.className.split(' ').filter(useClass).join(' ') || 'Style';
|
|
171
|
+
// sopts.previousElementSibling.innerHTML = classes;
|
|
172
|
+
// },
|
|
173
|
+
// click() {
|
|
174
|
+
// sopts.innerHTML = '';
|
|
175
|
+
// let el = qgSelection.isElement() || getSelection().isCollapsed ? state.element : null;
|
|
176
|
+
// // if (el === active) return;
|
|
177
|
+
// let classes = getPossibleClasses(el);
|
|
178
|
+
// for (let sty of Object.keys(classes)) {
|
|
179
|
+
// if (!useClass(sty)) return;
|
|
180
|
+
// let has = el && el.classList.contains(sty);
|
|
181
|
+
// let d = c1.dom.fragment('<div class="'+sty+'">'+sty+'</div>').firstChild;
|
|
182
|
+
// sopts.append(d);
|
|
183
|
+
// has && d.classList.add('-selected');
|
|
184
|
+
// d.onmousedown = function() {
|
|
185
|
+
// Rte.manipulate(()=>{
|
|
186
|
+
// if (!el) {
|
|
187
|
+
// el = qgSelection.surroundContents(document.createElement('span'));
|
|
188
|
+
// }
|
|
189
|
+
// el.classList.toggle(sty, !has);
|
|
190
|
+
// });
|
|
191
|
+
// };
|
|
192
|
+
// // d.css({
|
|
193
|
+
// // fontSize:parseInt(d.css('fontSize')).limit(9,18),
|
|
194
|
+
// // margin:parseInt(d.css('margin')).limit(0,4),
|
|
195
|
+
// // padding:parseInt(d.css('padding')).limit(0,4),
|
|
196
|
+
// // letterSpacing:parseInt(d.css('letterSpacing')).limit(0,11),
|
|
197
|
+
// // borderWidth:parseInt(d.css('borderWidth')).limit(0,4)
|
|
198
|
+
// // });
|
|
199
|
+
// }
|
|
200
|
+
// }
|
|
201
|
+
// });
|
|
202
|
+
// }
|
|
203
|
+
|
|
204
|
+
/* show invisibles *
|
|
205
|
+
{
|
|
206
|
+
function replaceContents(node){
|
|
207
|
+
for (const el of node.childNodes) replaceNode(el);
|
|
208
|
+
}
|
|
209
|
+
function replaceNode(node) {
|
|
210
|
+
if (node.nodeType === 3) { // text-nodes
|
|
211
|
+
let offset = 0;
|
|
212
|
+
for (const char of node.data) {
|
|
213
|
+
if (char === '\xa0') { // nbsp
|
|
214
|
+
//var x = node.splitText(offset);
|
|
215
|
+
}
|
|
216
|
+
++offset;
|
|
217
|
+
}
|
|
218
|
+
} else {
|
|
219
|
+
replaceContents(node);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
Rte.ui.setItem('ShowInvisibleChars', {
|
|
223
|
+
click(e) {
|
|
224
|
+
let root = active;
|
|
225
|
+
replaceContents(root);
|
|
226
|
+
}
|
|
227
|
+
,shortcut:'space'
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
/* clean / remove format */
|
|
231
|
+
{
|
|
232
|
+
const removeTags = ['FONT','O:P','SDFIELD','SPAN'].reduce((obj, item)=>{ obj[item]=1; return obj; }, {});
|
|
233
|
+
const removeAttrs = ['style','class','align','valign','border','cellpadding','cellspacing','bgcolor'];
|
|
234
|
+
function cleanNode(node) {
|
|
235
|
+
if (!node) return;
|
|
236
|
+
cleanContents(node);
|
|
237
|
+
node.nodeType === Node.COMMENT_NODE && node.remove();
|
|
238
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
239
|
+
removeTags[node.tagName] && node.removeNode();
|
|
240
|
+
removeAttrs.forEach(attr=>node.removeAttribute(attr));
|
|
241
|
+
if (node.tagName !== 'IMG') ['width','height'].forEach(attr=>node.removeAttribute(attr))
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function cleanContents(node){
|
|
245
|
+
if (node.childNodes) for (let child of node.childNodes) cleanNode(child);
|
|
246
|
+
}
|
|
247
|
+
Rte.ui.setItem('Removeformat', {
|
|
248
|
+
click() {
|
|
249
|
+
const root = state.range.callapsed ? active : state.range.commonAncestorContainer;
|
|
250
|
+
cleanContents(root);
|
|
251
|
+
},
|
|
252
|
+
shortcut:'space',
|
|
253
|
+
icon: 'format-clear',
|
|
254
|
+
labels: lang.Removeformat
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
/* insert table */
|
|
260
|
+
Rte.ui.setItem('Table', {
|
|
261
|
+
icon: 'grid-on',
|
|
262
|
+
click() {
|
|
263
|
+
let table = document.createElement('table');
|
|
264
|
+
table.innerHTML = '<tr><td> <td> <tr><td> <td> ';
|
|
265
|
+
$range(state.range).deleteContents().insert(table).collapse(table.querySelector('td'),0).select();
|
|
266
|
+
},
|
|
267
|
+
enable(){
|
|
268
|
+
return !blocklessElements[active.tagName];
|
|
269
|
+
},
|
|
270
|
+
labels: lang.Table
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
/* Target *
|
|
275
|
+
Rte.ui.setItem('LinkTarget', {
|
|
276
|
+
enable:'a, a > *',
|
|
277
|
+
check(el) {
|
|
278
|
+
el = el.closest('a');
|
|
279
|
+
let target = el.getAttribute('target');
|
|
280
|
+
return target && target !== '_self';
|
|
281
|
+
},
|
|
282
|
+
click(){
|
|
283
|
+
let el = state.element.closest('a');
|
|
284
|
+
let active = this.el.classList.contains('active');
|
|
285
|
+
el.setAttribute('target', active?'_self':'_blank');
|
|
286
|
+
Rte.trigger('input');
|
|
287
|
+
active.focus();
|
|
288
|
+
Rte.trigger('elementchange');
|
|
289
|
+
},
|
|
290
|
+
el: c1.dom.fragment('<div class="-item -button">Link in neuem Fenster</div>').firstChild
|
|
291
|
+
});
|
|
292
|
+
/* Titletag *
|
|
293
|
+
{
|
|
294
|
+
let el = c1.dom.fragment('<table style="clear:both"><tr><td style="width:84px">Titel<td><input>').firstChild;
|
|
295
|
+
let inp = el.c1Find('input');
|
|
296
|
+
inp.addEventListener('keyup', function() {
|
|
297
|
+
state.element.setAttribute('title',inp.value);
|
|
298
|
+
!inp.value && state.element.removeAttribute('title');
|
|
299
|
+
Rte.trigger('input');
|
|
300
|
+
});
|
|
301
|
+
Rte.ui.setItem('AttributeTitle',{
|
|
302
|
+
check(el) {
|
|
303
|
+
inp.value = el ? el.getAttribute('title') : '';
|
|
304
|
+
},
|
|
305
|
+
el: el
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// /* Image Attributes */
|
|
310
|
+
// {
|
|
311
|
+
// let inp = document.createElement('table');
|
|
312
|
+
// inp.innerHTML =
|
|
313
|
+
// '<tr><td style="width:84px">Breite:<td><input class=-x>'+
|
|
314
|
+
// '<tr><td>Höhe:<td><input class=-y>'+
|
|
315
|
+
// '<tr><td title="Alternativer Text">Alt-Text:<td><input class=-alt>';
|
|
316
|
+
|
|
317
|
+
// inp.addEventListener('keyup',e=>{
|
|
318
|
+
// let img = state.element;
|
|
319
|
+
// img.style.width = inp.querySelector('.-x').value+'px';
|
|
320
|
+
// img.style.height = inp.querySelector('.-y').value+'px';
|
|
321
|
+
// img.setAttribute('alt', inp.querySelector('.-alt').value);
|
|
322
|
+
// if (e.target.classList.contains('-x') || e.target.classList.contains('-y')) {
|
|
323
|
+
// state.element.dispatchEvent(new Event('qgResize',{bubbles:true}));
|
|
324
|
+
// }
|
|
325
|
+
// active.dispatchEvent(new Event('input',{'bubbles':true,'cancelable':true})); // used!
|
|
326
|
+
// })
|
|
327
|
+
// Rte.ui.setItem('ImageDimension', {
|
|
328
|
+
// check(el) {
|
|
329
|
+
// inp.querySelector('.-x').value = el.offsetWidth;
|
|
330
|
+
// inp.querySelector('.-y').value = el.offsetHeight;
|
|
331
|
+
// inp.querySelector('.-alt').value = el.getAttribute('alt');
|
|
332
|
+
// },
|
|
333
|
+
// el:inp,
|
|
334
|
+
// enable:'img'
|
|
335
|
+
// });
|
|
336
|
+
// }
|
|
337
|
+
/* Image Attributes */
|
|
338
|
+
{
|
|
339
|
+
const el = document.createElement('label');
|
|
340
|
+
el.innerHTML = '<small>Alternativer Text:</small><input placeholder="Alternative Text">';
|
|
341
|
+
let inp = el.querySelector('input');
|
|
342
|
+
inp.addEventListener('keyup',e=>{
|
|
343
|
+
let img = state.element;
|
|
344
|
+
img.setAttribute('alt', inp.value);
|
|
345
|
+
active.dispatchEvent(new Event('input',{'bubbles':true,'cancelable':true}));
|
|
346
|
+
})
|
|
347
|
+
Rte.ui.setItem('alt-text', {
|
|
348
|
+
check(el) {
|
|
349
|
+
inp.value = el.getAttribute('alt');
|
|
350
|
+
},
|
|
351
|
+
el:el,
|
|
352
|
+
enable:'img'
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
/* original image *
|
|
358
|
+
const imgSizeCache = {};
|
|
359
|
+
function ImageRealSize(url, cb) {
|
|
360
|
+
if (!imgSizeCache[url]) {
|
|
361
|
+
const nImg = new Image();
|
|
362
|
+
nImg.src = url;
|
|
363
|
+
nImg.onload = function() {
|
|
364
|
+
cb.apply(null, imgSizeCache[url] = [nImg.width, nImg.height]);
|
|
365
|
+
};
|
|
366
|
+
} else {
|
|
367
|
+
cb.apply(null,imgSizeCache[url]);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
Rte.ui.setItem('ImgOriginal', {
|
|
371
|
+
enable: 'img',
|
|
372
|
+
click(e) {
|
|
373
|
+
let img = state.element;
|
|
374
|
+
let url = img.getAttribute('src').replace(/\/(w|h|zoom|vpos|hpos|dpr)-[^\/]+/g,'');
|
|
375
|
+
ImageRealSize(url, function(w,h) {
|
|
376
|
+
w /= 2; h /= 2; // vorgängig wird dem Server per Cookie mitteilt, dass er die doppelte Auflösung ausliefern soll
|
|
377
|
+
make(w,h);
|
|
378
|
+
});
|
|
379
|
+
function make(w,h) {
|
|
380
|
+
img.setAttribute('src',url);
|
|
381
|
+
img.setAttribute('width',w);
|
|
382
|
+
img.setAttribute('height',h);
|
|
383
|
+
img.style.width = '';
|
|
384
|
+
img.style.maxWidth = '100%';
|
|
385
|
+
img.style.height = 'auto';
|
|
386
|
+
state.element.dispatchEvent(new Event('qgResize',{bubbles:true})); // new
|
|
387
|
+
Rte.trigger('input');
|
|
388
|
+
Rte.trigger('elementchange');
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
el: c1.dom.fragment('<span class="-item -button" title="Originalgrösse">Originalbild</span>').firstChild
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
/* table handles *
|
|
395
|
+
import {TableHandles} from '../c1/tableHandles.mjs?qgUniq=bbcd4cc';
|
|
396
|
+
{
|
|
397
|
+
let td, tr, table, index;
|
|
398
|
+
let handles = new TableHandles();
|
|
399
|
+
Rte.on('deactivate',() => handles.hide() );
|
|
400
|
+
function positionize() {
|
|
401
|
+
let e = state.element;
|
|
402
|
+
if (!e) return;
|
|
403
|
+
td = e.closest('td');
|
|
404
|
+
if (active && active.contains(td)) {
|
|
405
|
+
tr = td.parentNode;
|
|
406
|
+
table = tr.closest('table');
|
|
407
|
+
index = td.cellIndex;
|
|
408
|
+
handles.showTd(td);
|
|
409
|
+
} else {
|
|
410
|
+
handles.hide();
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
Rte.on('elementchange activate', positionize);
|
|
414
|
+
handles.root.addEventListener('click',e=>{
|
|
415
|
+
if (e.target.classList.contains('-rowRemove')) {
|
|
416
|
+
tr.remove();
|
|
417
|
+
}
|
|
418
|
+
if (e.target.classList.contains('-rowAdd')) {
|
|
419
|
+
const tr2 = tr.cloneNode(true);
|
|
420
|
+
tr.after(tr2)
|
|
421
|
+
}
|
|
422
|
+
if (e.target.classList.contains('-colRemove')) {
|
|
423
|
+
const trs = table.c1FindAll('> * > tr');
|
|
424
|
+
for (const tr of trs) tr.children[index].remove();
|
|
425
|
+
}
|
|
426
|
+
if (e.target.classList.contains('-colAdd')) {
|
|
427
|
+
const trs = table.c1FindAll('> * > tr');
|
|
428
|
+
for (const tr of trs) {
|
|
429
|
+
const td = c1.dom.fragment('<td><br></td>'); // firefox needs <br> to be able to navigate to the cell
|
|
430
|
+
tr.children[index].after(td);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
const hasTds = table.c1FindAll('> * > tr > *').length;
|
|
434
|
+
!hasTds && table.remove();
|
|
435
|
+
getSelection().modify('move', 'right', 'character'); // chrome bug
|
|
436
|
+
getSelection().modify('move', 'left', 'character');
|
|
437
|
+
Rte.checkSelection();
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
/* */
|
|
441
|
+
|
|
442
|
+
// Rte.ui.config = { zzz
|
|
443
|
+
// rteDef:{
|
|
444
|
+
// main:['LinkInput','Bold','Italic','Insertunorderedlist','Insertorderedlist','Link','Removeformat','Format','Style','Strikethrough','Underlined','Hr','Code','Table','Shy',/*'ShowInvisibleChars',*/'LinkTarget','ImgOriginal','ImgOriginalRetina',/*'AttributeTitle',*/'ImageDimension','Tree']
|
|
445
|
+
// },
|
|
446
|
+
// };
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
/* *
|
|
451
|
+
{ // show shy, todo: deprecated? css hyphens and text-wrap:balance are widely supported
|
|
452
|
+
Rte.ui.setItem('Shy',{
|
|
453
|
+
click() {
|
|
454
|
+
const span = document.createElement('span');
|
|
455
|
+
span.className = 'qgRte-mark-char -Shy';
|
|
456
|
+
span.textContent = '\u00AD';
|
|
457
|
+
$range(state.range).deleteContents().insert(span).collapse().select();
|
|
458
|
+
},
|
|
459
|
+
labels: {
|
|
460
|
+
de: 'Weiches Trennzeichen einfügen',
|
|
461
|
+
en: 'Insert soft hyphen',
|
|
462
|
+
fr: 'Insérer un trait d\'union doux',
|
|
463
|
+
},
|
|
464
|
+
//el: c1.dom.fragment('<div class="-item -button">Weiches Trennzeichen einfügen</div>').firstChild
|
|
465
|
+
});
|
|
466
|
+
const style = document.createElement('style');
|
|
467
|
+
style.innerHTML = '.qgRte-mark-char.-Shy::after { content:"-"; display:inline-block; color:#f88; opacity:.6; } ';
|
|
468
|
+
document.head.appendChild(style);
|
|
469
|
+
|
|
470
|
+
function addMarks(){
|
|
471
|
+
// remove
|
|
472
|
+
var anchor = getSelection().anchorNode;
|
|
473
|
+
if (!anchor) return;
|
|
474
|
+
anchor.parentNode.querySelectorAll('.qgRte-mark-char').forEach(function(marker){
|
|
475
|
+
if (!marker.firstChild) marker.remove();
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
//matchText(active, new RegExp('\u00AD|\u00a0', 'g'), function(node, match, offset) {
|
|
479
|
+
matchText(active, new RegExp('\u00AD', 'g'), function(node, match, offset) {
|
|
480
|
+
if (node.parentNode.classList.contains('qgRte-mark-char')) return false;
|
|
481
|
+
var span = document.createElement('span');
|
|
482
|
+
span.className = 'qgRte-mark-char';
|
|
483
|
+
if (match === '\u00AD') span.className += ' -Shy';
|
|
484
|
+
//if (match === '\u00a0') span.className += ' -Nbsp';
|
|
485
|
+
span.textContent = match;
|
|
486
|
+
return span;
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
function removeMarks(){
|
|
490
|
+
active.querySelectorAll('.qgRte-mark-char').forEach(el=>el.removeNode())
|
|
491
|
+
active.normalize();
|
|
492
|
+
}
|
|
493
|
+
Rte.on('activate',addMarks);
|
|
494
|
+
Rte.on('input',addMarks);
|
|
495
|
+
Rte.on('deactivate',removeMarks);
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
var matchText = function(node, regex, callback, excludeElements) {
|
|
499
|
+
excludeElements || (excludeElements = ['script', 'style', 'iframe', 'canvas']);
|
|
500
|
+
var child = node.firstChild;
|
|
501
|
+
while (child) {
|
|
502
|
+
if (child.nodeType === 1) {
|
|
503
|
+
if (excludeElements.indexOf(child.tagName.toLowerCase()) > -1) break;
|
|
504
|
+
matchText(child, regex, callback, excludeElements);
|
|
505
|
+
}
|
|
506
|
+
if (child.nodeType === 3) {
|
|
507
|
+
var bk = 0;
|
|
508
|
+
child.data.replace(regex, function(str) {
|
|
509
|
+
var args = [].slice.call(arguments);
|
|
510
|
+
var tag = callback.apply(window, [child].concat(args));
|
|
511
|
+
if (!tag) return false;
|
|
512
|
+
var offset = args[args.length - 2];
|
|
513
|
+
var newTextNode = child.splitText(offset+bk);
|
|
514
|
+
bk -= child.data.length + str.length;
|
|
515
|
+
newTextNode.data = newTextNode.data.substr(str.length);
|
|
516
|
+
child.parentNode.insertBefore(tag, newTextNode);
|
|
517
|
+
child = newTextNode;
|
|
518
|
+
});
|
|
519
|
+
regex.lastIndex = 0;
|
|
520
|
+
}
|
|
521
|
+
child = child.nextSibling;
|
|
522
|
+
}
|
|
523
|
+
return node;
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
}
|
|
527
|
+
/* */
|
|
528
|
+
|
|
529
|
+
/* *
|
|
530
|
+
{ // show line-breaks
|
|
531
|
+
const style = document.createElement('style');
|
|
532
|
+
style.innerHTML =
|
|
533
|
+
'.qgRte-mark-char.-Br::before { '+
|
|
534
|
+
' content:"↵";'+
|
|
535
|
+
' display:inline;'+
|
|
536
|
+
' display:contents;'+
|
|
537
|
+
' opacity:.3;'+
|
|
538
|
+
' margin-left:.2em; '+
|
|
539
|
+
' font-size:.82em; '+
|
|
540
|
+
' pointer-events:none; '+ // I don't think it'll do any good
|
|
541
|
+
'}'
|
|
542
|
+
document.head.appendChild(style);
|
|
543
|
+
// document.head.append(
|
|
544
|
+
// c1.dom.fragment(
|
|
545
|
+
// '<style>'+
|
|
546
|
+
// '.qgRte-mark-char.-Br::before { '+
|
|
547
|
+
// ' content:"↵";'+
|
|
548
|
+
// ' display:inline;'+
|
|
549
|
+
// ' display:contents;'+
|
|
550
|
+
// ' opacity:.3;'+
|
|
551
|
+
// ' margin-left:.2em; '+
|
|
552
|
+
// ' font-size:.82em; '+
|
|
553
|
+
// ' pointer-events:none; '+ // I don't think it'll do any good
|
|
554
|
+
// '}'+
|
|
555
|
+
// '</style>')
|
|
556
|
+
// );
|
|
557
|
+
function addMarks(){
|
|
558
|
+
if (!active) return;
|
|
559
|
+
active.querySelectorAll('br').forEach(br=>{
|
|
560
|
+
if (br.previousElementSibling?.classList.contains('-Br')) return;
|
|
561
|
+
const span = document.createElement('span');
|
|
562
|
+
span.className = 'qgRte-mark-char -Br';
|
|
563
|
+
br.before(span);
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
addEventListener('u2-rte-activate',addMarks);
|
|
567
|
+
addEventListener('u2-rte-deactivate',addMarks);
|
|
568
|
+
//Rte.on('activate',addMarks);
|
|
569
|
+
//Rte.on('input',addMarks);
|
|
570
|
+
}
|
|
571
|
+
/* */
|