From 4b4f7937a39d34793478a86fe10520fa0585e595 Mon Sep 17 00:00:00 2001 From: Anna Dabrowska Date: Wed, 13 Dec 2023 12:49:45 +0100 Subject: [PATCH] Improve handling of unformatted text (#197) - do not assume any pasted text that includes a span is unformatted (nowiki) - visually highlight unformatted text in editor - disable adding format marks (like bold) inside unformatted text - add 'unformatted' to text style dropdown Fixes #190 Addresses but does not yet resolve #101 --- lang/de/lang.php | 1 + lang/en/lang.php | 1 + script/plugins/Menu/MDI.js | 1 + script/plugins/Menu/MenuInitializer.js | 1 + script/schema.js | 4 +--- style.less | 7 ++++++- 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lang/de/lang.php b/lang/de/lang.php index 6e91e7c8..75e69793 100644 --- a/lang/de/lang.php +++ b/lang/de/lang.php @@ -92,6 +92,7 @@ $lang['js']['label:subscript'] = 'tief stellen'; $lang['js']['label:deleted'] = 'durchstreichen'; $lang['js']['label:monospaced'] = 'feste Zeichenbreite'; +$lang['js']['label:unformatted'] = 'Wiki-Formatierung ignorieren'; $lang['js']['label:undo'] = 'rückgängig machen'; $lang['js']['label:redo'] = 'wiederherstellen'; diff --git a/lang/en/lang.php b/lang/en/lang.php index 5089d4b8..4af822ab 100644 --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -92,6 +92,7 @@ $lang['js']['label:subscript'] = 'subscript'; $lang['js']['label:deleted'] = 'strike through'; $lang['js']['label:monospaced'] = 'monospaced'; +$lang['js']['label:unformatted'] = 'ignore wiki formatting'; $lang['js']['label:undo'] = 'undo'; $lang['js']['label:redo'] = 'redo'; diff --git a/script/plugins/Menu/MDI.js b/script/plugins/Menu/MDI.js index 05fea9b7..a63263f8 100644 --- a/script/plugins/Menu/MDI.js +++ b/script/plugins/Menu/MDI.js @@ -26,6 +26,7 @@ const paths = { 'format-underline': 'M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z', 'format-quote-close': 'M14,17H17L19,13V7H13V13H16M6,17H9L11,13V7H5V13H8L6,17Z', 'console-line': 'M13,19V16H21V19H13M8.5,13L2.47,7H6.71L11.67,11.95C12.25,12.54 12.25,13.5 11.67,14.07L6.74,19H2.5L8.5,13Z', + 'translate-off': 'M12.17,5.81C11.87,6.69 11.47,7.55 11,8.39L12.35,9.74C13.11,8.5 13.71,7.18 14.13,5.81H17.16V3.75H9.94V1.69H7.87V3.75H6.37L8.43,5.81H12.17M15.53,12.91L17.03,14.41L17.67,12.69L19.08,16.47L22.39,19.77L18.7,9.94H16.64L15.53,12.91M1.31,1.31L0,2.62L1.13,3.75H0.65V5.81H3.19L5.26,7.88H4.46C5.21,9.56 6.24,11.15 7.53,12.58L2.28,17.76L3.75,19.22L8.91,14.07L12.11,17.27L12.8,15.43L14.1,16.72L12,22.31H14.06L15.22,19.22H16.6L21.38,24L22.69,22.69L1.31,1.31Z', 'link-variant': 'M10.59,13.41C11,13.8 11,14.44 10.59,14.83C10.2,15.22 9.56,15.22 9.17,14.83C7.22,12.88 7.22,9.71 9.17,7.76V7.76L12.71,4.22C14.66,2.27 17.83,2.27 19.78,4.22C21.73,6.17 21.73,9.34 19.78,11.29L18.29,12.78C18.3,11.96 18.17,11.14 17.89,10.36L18.36,9.88C19.54,8.71 19.54,6.81 18.36,5.64C17.19,4.46 15.29,4.46 14.12,5.64L10.59,9.17C9.41,10.34 9.41,12.24 10.59,13.41M13.41,9.17C13.8,8.78 14.44,8.78 14.83,9.17C16.78,11.12 16.78,14.29 14.83,16.24V16.24L11.29,19.78C9.34,21.73 6.17,21.73 4.22,19.78C2.27,17.83 2.27,14.66 4.22,12.71L5.71,11.22C5.7,12.04 5.83,12.86 6.11,13.65L5.64,14.12C4.46,15.29 4.46,17.19 5.64,18.36C6.81,19.54 8.71,19.54 9.88,18.36L13.41,14.83C14.59,13.66 14.59,11.76 13.41,10.59C13,10.2 13,9.56 13.41,9.17Z', 'image': 'M8.5,13.5L11,16.5L14.5,12L19,18H5M21,19V5C21,3.89 20.1,3 19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19Z', 'arrow-expand-left': 'M20,22H22V2H20V11H5.83L11.33,5.5L9.92,4.08L2,12L9.92,19.92L11.33,18.5L5.83,13H20V22Z', diff --git a/script/plugins/Menu/MenuInitializer.js b/script/plugins/Menu/MenuInitializer.js index 54af38e5..52c8a692 100644 --- a/script/plugins/Menu/MenuInitializer.js +++ b/script/plugins/Menu/MenuInitializer.js @@ -65,6 +65,7 @@ class MenuInitializer { new MarkMenuItemDispatcher('subscript', 'format-subscript', lang['label:subscript']), new MarkMenuItemDispatcher('deleted', 'format-strikethrough', lang['label:deleted']), new MarkMenuItemDispatcher('code', 'console-line', lang['label:monospaced']), + new MarkMenuItemDispatcher('unformatted', 'translate-off', lang['label:unformatted']), ]), LinkMenuItemDispatcher, ImageMenuItemDispatcher, diff --git a/script/schema.js b/script/schema.js index 90de308c..6b5134f6 100644 --- a/script/schema.js +++ b/script/schema.js @@ -326,9 +326,7 @@ export default function getSpec() { }); marks = marks.addToEnd('unformatted', { - parseDOM: [ - { tag: 'span', class: 'unformatted' }, - ], + excludes: '_', toDOM() { return ['span', { class: 'unformatted' }]; }, diff --git a/style.less b/style.less index cf9796ca..aff28832 100644 --- a/style.less +++ b/style.less @@ -61,6 +61,11 @@ } } + span.unformatted { + padding: 0.2rem; + border: 1px dotted @ini_border; + } + .footnote { &::after { content: counter(prosemirror-footnote) ')'; @@ -97,7 +102,7 @@ } div.dropdown_content { - width: 10rem; + min-width: 12rem; img { max-width: 1.5rem;