lexxy 0.1.21.beta → 0.1.22.beta

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.
@@ -5207,6 +5207,21 @@ function extendConversion(nodeKlass, conversionName, callback = (output => outpu
5207
5207
  }
5208
5208
  }
5209
5209
 
5210
+ function isSelectionHighlighted(selection) {
5211
+ if (!yr(selection)) return false
5212
+
5213
+ if (selection.isCollapsed()) {
5214
+ return hasHighlightStyles(selection.style)
5215
+ } else {
5216
+ return selection.hasFormat("highlight")
5217
+ }
5218
+ }
5219
+
5220
+ function hasHighlightStyles(cssOrStyles) {
5221
+ const styles = typeof cssOrStyles === "string" ? b$3(cssOrStyles) : cssOrStyles;
5222
+ return !!(styles.color || styles["background-color"])
5223
+ }
5224
+
5210
5225
  class LexicalToolbarElement extends HTMLElement {
5211
5226
  constructor() {
5212
5227
  super();
@@ -5359,7 +5374,7 @@ class LexicalToolbarElement extends HTMLElement {
5359
5374
  const isBold = selection.hasFormat("bold");
5360
5375
  const isItalic = selection.hasFormat("italic");
5361
5376
  const isStrikethrough = selection.hasFormat("strikethrough");
5362
- const isHighlight = selection.hasFormat("highlight");
5377
+ const isHighlight = isSelectionHighlighted(selection);
5363
5378
  const isInLink = this.#isInLink(anchorNode);
5364
5379
  const isInQuote = Ot$1(topLevelElement);
5365
5380
  const isInHeading = It$1(topLevelElement);
@@ -5516,53 +5531,944 @@ class LexicalToolbarElement extends HTMLElement {
5516
5531
  <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12.111 9.546a1.5 1.5 0 012.121 0 5.5 5.5 0 010 7.778l-2.828 2.828a5.5 5.5 0 01-7.778 0 5.498 5.498 0 010-7.777l2.828-2.83a1.5 1.5 0 01.355-.262 6.52 6.52 0 00.351 3.799l-1.413 1.414a2.499 2.499 0 000 3.535 2.499 2.499 0 003.535 0l2.83-2.828a2.5 2.5 0 000-3.536 1.5 1.5 0 010-2.121z"/><path d="M12.111 3.89a5.5 5.5 0 117.778 7.777l-2.828 2.829a1.496 1.496 0 01-.355.262 6.522 6.522 0 00-.351-3.8l1.413-1.412a2.5 2.5 0 10-3.536-3.535l-2.828 2.828a2.5 2.5 0 000 3.536 1.5 1.5 0 01-2.122 2.12 5.5 5.5 0 010-7.777l2.83-2.829z"/></svg>
5517
5532
  </button>
5518
5533
 
5519
- <button class="lexxy-editor__toolbar-button" type="button" name="quote" data-command="insertQuoteBlock" title="Quote">
5520
- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M6.5 5C8.985 5 11 7.09 11 9.667c0 2.694-.962 5.005-2.187 6.644-.613.82-1.3 1.481-1.978 1.943-.668.454-1.375.746-2.022.746a.563.563 0 01-.52-.36.602.602 0 01.067-.57l.055-.066.009-.009.041-.048a4.25 4.25 0 00.168-.21c.143-.188.336-.47.53-.84a6.743 6.743 0 00.75-2.605C3.705 13.994 2 12.038 2 9.667 2 7.089 4.015 5 6.5 5zM17.5 5C19.985 5 22 7.09 22 9.667c0 2.694-.962 5.005-2.187 6.644-.613.82-1.3 1.481-1.978 1.943-.668.454-1.375.746-2.023.746a.563.563 0 01-.52-.36.602.602 0 01.068-.57l.055-.066.009-.009.041-.048c.039-.045.097-.115.168-.21a6.16 6.16 0 00.53-.84 6.745 6.745 0 00.75-2.605C14.705 13.994 13 12.038 13 9.667 13 7.089 15.015 5 17.5 5z"/></svg>
5521
- </button>
5534
+ <button class="lexxy-editor__toolbar-button" type="button" name="quote" data-command="insertQuoteBlock" title="Quote">
5535
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M6.5 5C8.985 5 11 7.09 11 9.667c0 2.694-.962 5.005-2.187 6.644-.613.82-1.3 1.481-1.978 1.943-.668.454-1.375.746-2.022.746a.563.563 0 01-.52-.36.602.602 0 01.067-.57l.055-.066.009-.009.041-.048a4.25 4.25 0 00.168-.21c.143-.188.336-.47.53-.84a6.743 6.743 0 00.75-2.605C3.705 13.994 2 12.038 2 9.667 2 7.089 4.015 5 6.5 5zM17.5 5C19.985 5 22 7.09 22 9.667c0 2.694-.962 5.005-2.187 6.644-.613.82-1.3 1.481-1.978 1.943-.668.454-1.375.746-2.023.746a.563.563 0 01-.52-.36.602.602 0 01.068-.57l.055-.066.009-.009.041-.048c.039-.045.097-.115.168-.21a6.16 6.16 0 00.53-.84 6.745 6.745 0 00.75-2.605C14.705 13.994 13 12.038 13 9.667 13 7.089 15.015 5 17.5 5z"/></svg>
5536
+ </button>
5537
+
5538
+ <button class="lexxy-editor__toolbar-button" type="button" name="heading" data-command="rotateHeadingFormat" title="Heading">
5539
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M15.322 5.315H9.64V22H5.684V5.315H0v-3.31h15.322v3.31z"/><path d="M23.957 11.79H19.92V22h-3.402V11.79H12.48V9.137h11.477v2.653z"/></svg>
5540
+ </button>
5541
+
5542
+ <button class="lexxy-editor__toolbar-button" type="button" name="code" data-command="insertCodeBlock" title="Code">
5543
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M10.121 6l-6 6 6 6-2.12 2.121-7.061-7.06a1.5 1.5 0 010-2.121L8 3.879 10.121 6zM23.06 10.94a1.5 1.5 0 010 2.12L16 20.121 13.88 18l6-6-6-6L16 3.879l7.06 7.06z"/></svg>
5544
+ </button>
5545
+
5546
+ <button class="lexxy-editor__toolbar-button" type="button" name="unordered-list" data-command="insertUnorderedList" title="Bullet list">
5547
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M5 5a2 2 0 11-4 0 2 2 0 014 0zM5 12a2 2 0 11-4 0 2 2 0 014 0zM5 19a2 2 0 11-4 0 2 2 0 014 0zM7 5.25C7 4.56 7.56 4 8.25 4h13.5a1.25 1.25 0 110 2.5H8.25C7.56 6.5 7 5.94 7 5.25zM7 12.25c0-.69.56-1.25 1.25-1.25h13.5a1.25 1.25 0 110 2.5H8.25c-.69 0-1.25-.56-1.25-1.25zM7 19.25c0-.69.56-1.25 1.25-1.25h13.5a1.25 1.25 0 110 2.5H8.25c-.69 0-1.25-.56-1.25-1.25z"/></svg>
5548
+ </button>
5549
+
5550
+ <button class="lexxy-editor__toolbar-button" type="button" name="ordered-list" data-command="insertOrderedList" title="Numbered list">
5551
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.25C7 4.56 7.56 4 8.25 4h13.5a1.25 1.25 0 110 2.5H8.25C7.56 6.5 7 5.94 7 5.25zM7 12.25c0-.69.56-1.25 1.25-1.25h13.5a1.25 1.25 0 110 2.5H8.25c-.69 0-1.25-.56-1.25-1.25zM7 19.25c0-.69.56-1.25 1.25-1.25h13.5a1.25 1.25 0 110 2.5H8.25c-.69 0-1.25-.56-1.25-1.25zM4.438 8H3.39V3.684H3.34c-.133.093-.267.188-.402.285l-.407.289a129.5 129.5 0 00-.402.285v-.969l.633-.453c.21-.15.42-.302.629-.453h1.046V8zM2.672 11.258h-1v-.051c0-.206.036-.405.11-.598.075-.195.188-.37.34-.527.15-.156.339-.281.566-.375.229-.094.498-.14.808-.14.367 0 .688.065.961.195s.484.308.633.535c.15.224.226.478.226.762 0 .244-.046.463-.14.656-.091.19-.209.368-.352.535-.14.164-.289.332-.445.504L3.168 14.09v.05h2.238V15H1.723v-.656l1.949-2.102c.096-.101.19-.207.281-.316.091-.112.167-.232.227-.36a.953.953 0 00.09-.41.712.712 0 00-.387-.648.845.845 0 00-.41-.098.81.81 0 00-.43.11.75.75 0 00-.277.293.824.824 0 00-.094.386V11.258zM2.852 19.66v-.812h.562a.917.917 0 00.43-.098.742.742 0 00.293-.266.673.673 0 00.101-.379.654.654 0 00-.234-.523.87.87 0 00-.59-.2.987.987 0 00-.336.055.837.837 0 00-.258.149.712.712 0 00-.172.215.66.66 0 00-.066.25h-.98c.007-.209.053-.403.136-.582.084-.18.203-.336.36-.469.156-.135.346-.24.57-.316.227-.076.486-.115.777-.118a2.33 2.33 0 01.965.176c.271.12.48.285.63.496.15.209.227.448.23.719a1.11 1.11 0 01-.16.637 1.28 1.28 0 01-.825.586v.054c.162.016.33.07.504.164.177.094.328.232.453.415.125.18.189.411.192.695a1.37 1.37 0 01-.157.676c-.104.197-.25.365-.437.503-.188.136-.404.24-.649.313-.242.07-.5.105-.777.105-.401 0-.743-.067-1.027-.203a1.608 1.608 0 01-.649-.547 1.46 1.46 0 01-.238-.75h.969c.01.128.057.243.14.344a.885.885 0 00.332.238c.141.058.3.088.477.09.195 0 .366-.034.512-.101a.798.798 0 00.336-.29.744.744 0 00.117-.425.74.74 0 00-.446-.695 1.082 1.082 0 00-.496-.106h-.59z"/></svg>
5552
+ </button>
5553
+
5554
+ <button class="lexxy-editor__toolbar-button" type="button" name="upload" data-command="uploadAttachments" title="Upload file">
5555
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M16 8a2 2 0 110 4 2 2 0 010-4z""/><path d="M22 2a1 1 0 011 1v18a1 1 0 01-1 1H2a1 1 0 01-1-1V3a1 1 0 011-1h20zM3 18.714L9 11l5.25 6.75L17 15l4 4V4H3v14.714z"/></svg>
5556
+ </button>
5557
+
5558
+ <button class="lexxy-editor__toolbar-button" type="button" name="divider" data-command="insertHorizontalDivider" title="Insert a divider">
5559
+ <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 12C0 11.4477 0.447715 11 1 11H23C23.5523 11 24 11.4477 24 12C24 12.5523 23.5523 13 23 13H1C0.447716 13 0 12.5523 0 12Z"/><path d="M4 5C4 3.89543 4.89543 3 6 3H18C19.1046 3 20 3.89543 20 5C20 6.10457 19.1046 7 18 7H6C4.89543 7 4 6.10457 4 5Z"/><path d="M4 19C4 17.8954 4.89543 17 6 17H18C19.1046 17 20 17.8954 20 19C20 20.1046 19.1046 21 18 21H6C4.89543 21 4 20.1046 4 19Z"/></svg>
5560
+ </button>
5561
+
5562
+ <div class="lexxy-editor__toolbar-spacer" role="separator"></div>
5563
+
5564
+ <button class="lexxy-editor__toolbar-button" type="button" name="undo" data-command="undo" title="Undo" data-hotkey="cmd+z ctrl+z">
5565
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M5.64648 8.26531C7.93911 6.56386 10.7827 5.77629 13.624 6.05535C16.4655 6.33452 19.1018 7.66079 21.0195 9.77605C22.5839 11.5016 23.5799 13.6516 23.8936 15.9352C24.0115 16.7939 23.2974 17.4997 22.4307 17.4997C21.5641 17.4997 20.8766 16.7915 20.7148 15.9401C20.4295 14.4379 19.7348 13.0321 18.6943 11.8844C17.3 10.3464 15.3835 9.38139 13.3174 9.17839C11.2514 8.97546 9.18359 9.54856 7.5166 10.7858C6.38259 11.6275 5.48981 12.7361 4.90723 13.9997H8.5C9.3283 13.9997 9.99979 14.6714 10 15.4997C10 16.3281 9.32843 16.9997 8.5 16.9997H1.5C0.671573 16.9997 0 16.3281 0 15.4997V8.49968C0.000213656 7.67144 0.671705 6.99968 1.5 6.99968C2.3283 6.99968 2.99979 7.67144 3 8.49968V11.0212C3.7166 9.9704 4.60793 9.03613 5.64648 8.26531Z"/></svg>
5566
+ </button>
5567
+
5568
+ <button class="lexxy-editor__toolbar-button" type="button" name="redo" data-command="redo" title="Redo" data-hotkey="cmd+shift+z ctrl+shift+z ctrl+y">
5569
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M18.2599 8.26531C15.9672 6.56386 13.1237 5.77629 10.2823 6.05535C7.4408 6.33452 4.80455 7.66079 2.88681 9.77605C1.32245 11.5016 0.326407 13.6516 0.0127834 15.9352C-0.105117 16.7939 0.608975 17.4997 1.47567 17.4997C2.34228 17.4997 3.02969 16.7915 3.19149 15.9401C3.47682 14.4379 4.17156 13.0321 5.212 11.8844C6.60637 10.3464 8.52287 9.38139 10.589 9.17839C12.655 8.97546 14.7227 9.54856 16.3897 10.7858C17.5237 11.6275 18.4165 12.7361 18.9991 13.9997H15.4063C14.578 13.9997 13.9066 14.6714 13.9063 15.4997C13.9063 16.3281 14.5779 16.9997 15.4063 16.9997H22.4063C23.2348 16.9997 23.9063 16.3281 23.9063 15.4997V8.49968C23.9061 7.67144 23.2346 6.99968 22.4063 6.99968C21.578 6.99968 20.9066 7.67144 20.9063 8.49968V11.0212C20.1897 9.9704 19.2984 9.03613 18.2599 8.26531Z"/></svg>
5570
+ </button>
5571
+
5572
+ <details class="lexxy-editor__toolbar-overflow">
5573
+ <summary class="lexxy-editor__toolbar-button" aria-label="Show more toolbar buttons">•••</summary>
5574
+ <div class="lexxy-editor__toolbar-overflow-menu" aria-label="More toolbar buttons"></div>
5575
+ </details>
5576
+ `
5577
+ }
5578
+ }
5579
+
5580
+ customElements.define("lexxy-toolbar", LexicalToolbarElement);
5581
+
5582
+ /**
5583
+ * Original by Samuel Flores
5584
+ *
5585
+ * Adds the following new token classes:
5586
+ * constant, builtin, variable, symbol, regex
5587
+ */
5588
+ (function (Prism) {
5589
+ Prism.languages.ruby = Prism.languages.extend('clike', {
5590
+ 'comment': {
5591
+ pattern: /#.*|^=begin\s[\s\S]*?^=end/m,
5592
+ greedy: true
5593
+ },
5594
+ 'class-name': {
5595
+ pattern: /(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,
5596
+ lookbehind: true,
5597
+ inside: {
5598
+ 'punctuation': /[.\\]/
5599
+ }
5600
+ },
5601
+ 'keyword': /\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,
5602
+ 'operator': /\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,
5603
+ 'punctuation': /[(){}[\].,;]/,
5604
+ });
5605
+
5606
+ Prism.languages.insertBefore('ruby', 'operator', {
5607
+ 'double-colon': {
5608
+ pattern: /::/,
5609
+ alias: 'punctuation'
5610
+ },
5611
+ });
5612
+
5613
+ var interpolation = {
5614
+ pattern: /((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,
5615
+ lookbehind: true,
5616
+ inside: {
5617
+ 'content': {
5618
+ pattern: /^(#\{)[\s\S]+(?=\}$)/,
5619
+ lookbehind: true,
5620
+ inside: Prism.languages.ruby
5621
+ },
5622
+ 'delimiter': {
5623
+ pattern: /^#\{|\}$/,
5624
+ alias: 'punctuation'
5625
+ }
5626
+ }
5627
+ };
5628
+
5629
+ delete Prism.languages.ruby.function;
5630
+
5631
+ var percentExpression = '(?:' + [
5632
+ /([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
5633
+ /\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,
5634
+ /\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,
5635
+ /\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,
5636
+ /<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source
5637
+ ].join('|') + ')';
5638
+
5639
+ var symbolName = /(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;
5640
+
5641
+ Prism.languages.insertBefore('ruby', 'keyword', {
5642
+ 'regex-literal': [
5643
+ {
5644
+ pattern: RegExp(/%r/.source + percentExpression + /[egimnosux]{0,6}/.source),
5645
+ greedy: true,
5646
+ inside: {
5647
+ 'interpolation': interpolation,
5648
+ 'regex': /[\s\S]+/
5649
+ }
5650
+ },
5651
+ {
5652
+ pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,
5653
+ lookbehind: true,
5654
+ greedy: true,
5655
+ inside: {
5656
+ 'interpolation': interpolation,
5657
+ 'regex': /[\s\S]+/
5658
+ }
5659
+ }
5660
+ ],
5661
+ 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
5662
+ 'symbol': [
5663
+ {
5664
+ pattern: RegExp(/(^|[^:]):/.source + symbolName),
5665
+ lookbehind: true,
5666
+ greedy: true
5667
+ },
5668
+ {
5669
+ pattern: RegExp(/([\r\n{(,][ \t]*)/.source + symbolName + /(?=:(?!:))/.source),
5670
+ lookbehind: true,
5671
+ greedy: true
5672
+ },
5673
+ ],
5674
+ 'method-definition': {
5675
+ pattern: /(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,
5676
+ lookbehind: true,
5677
+ inside: {
5678
+ 'function': /\b\w+$/,
5679
+ 'keyword': /^self\b/,
5680
+ 'class-name': /^\w+/,
5681
+ 'punctuation': /\./
5682
+ }
5683
+ }
5684
+ });
5685
+
5686
+ Prism.languages.insertBefore('ruby', 'string', {
5687
+ 'string-literal': [
5688
+ {
5689
+ pattern: RegExp(/%[qQiIwWs]?/.source + percentExpression),
5690
+ greedy: true,
5691
+ inside: {
5692
+ 'interpolation': interpolation,
5693
+ 'string': /[\s\S]+/
5694
+ }
5695
+ },
5696
+ {
5697
+ pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,
5698
+ greedy: true,
5699
+ inside: {
5700
+ 'interpolation': interpolation,
5701
+ 'string': /[\s\S]+/
5702
+ }
5703
+ },
5704
+ {
5705
+ pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
5706
+ alias: 'heredoc-string',
5707
+ greedy: true,
5708
+ inside: {
5709
+ 'delimiter': {
5710
+ pattern: /^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,
5711
+ inside: {
5712
+ 'symbol': /\b\w+/,
5713
+ 'punctuation': /^<<[-~]?/
5714
+ }
5715
+ },
5716
+ 'interpolation': interpolation,
5717
+ 'string': /[\s\S]+/
5718
+ }
5719
+ },
5720
+ {
5721
+ pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
5722
+ alias: 'heredoc-string',
5723
+ greedy: true,
5724
+ inside: {
5725
+ 'delimiter': {
5726
+ pattern: /^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,
5727
+ inside: {
5728
+ 'symbol': /\b\w+/,
5729
+ 'punctuation': /^<<[-~]?'|'$/,
5730
+ }
5731
+ },
5732
+ 'string': /[\s\S]+/
5733
+ }
5734
+ }
5735
+ ],
5736
+ 'command-literal': [
5737
+ {
5738
+ pattern: RegExp(/%x/.source + percentExpression),
5739
+ greedy: true,
5740
+ inside: {
5741
+ 'interpolation': interpolation,
5742
+ 'command': {
5743
+ pattern: /[\s\S]+/,
5744
+ alias: 'string'
5745
+ }
5746
+ }
5747
+ },
5748
+ {
5749
+ pattern: /`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,
5750
+ greedy: true,
5751
+ inside: {
5752
+ 'interpolation': interpolation,
5753
+ 'command': {
5754
+ pattern: /[\s\S]+/,
5755
+ alias: 'string'
5756
+ }
5757
+ }
5758
+ }
5759
+ ]
5760
+ });
5761
+
5762
+ delete Prism.languages.ruby.string;
5763
+
5764
+ Prism.languages.insertBefore('ruby', 'number', {
5765
+ 'builtin': /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,
5766
+ 'constant': /\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/
5767
+ });
5768
+
5769
+ Prism.languages.rb = Prism.languages.ruby;
5770
+ }(Prism));
5771
+
5772
+ /**
5773
+ * Original by Aaron Harun: http://aahacreative.com/2012/07/31/php-syntax-highlighting-prism/
5774
+ * Modified by Miles Johnson: http://milesj.me
5775
+ * Rewritten by Tom Pavelec
5776
+ *
5777
+ * Supports PHP 5.3 - 8.0
5778
+ */
5779
+ (function (Prism) {
5780
+ var comment = /\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/;
5781
+ var constant = [
5782
+ {
5783
+ pattern: /\b(?:false|true)\b/i,
5784
+ alias: 'boolean'
5785
+ },
5786
+ {
5787
+ pattern: /(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,
5788
+ greedy: true,
5789
+ lookbehind: true,
5790
+ },
5791
+ {
5792
+ pattern: /(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,
5793
+ greedy: true,
5794
+ lookbehind: true,
5795
+ },
5796
+ /\b(?:null)\b/i,
5797
+ /\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/,
5798
+ ];
5799
+ var number = /\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i;
5800
+ var operator = /<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/;
5801
+ var punctuation = /[{}\[\](),:;]/;
5802
+
5803
+ Prism.languages.php = {
5804
+ 'delimiter': {
5805
+ pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
5806
+ alias: 'important'
5807
+ },
5808
+ 'comment': comment,
5809
+ 'variable': /\$+(?:\w+\b|(?=\{))/,
5810
+ 'package': {
5811
+ pattern: /(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
5812
+ lookbehind: true,
5813
+ inside: {
5814
+ 'punctuation': /\\/
5815
+ }
5816
+ },
5817
+ 'class-name-definition': {
5818
+ pattern: /(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,
5819
+ lookbehind: true,
5820
+ alias: 'class-name'
5821
+ },
5822
+ 'function-definition': {
5823
+ pattern: /(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,
5824
+ lookbehind: true,
5825
+ alias: 'function'
5826
+ },
5827
+ 'keyword': [
5828
+ {
5829
+ pattern: /(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,
5830
+ alias: 'type-casting',
5831
+ greedy: true,
5832
+ lookbehind: true
5833
+ },
5834
+ {
5835
+ pattern: /([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,
5836
+ alias: 'type-hint',
5837
+ greedy: true,
5838
+ lookbehind: true
5839
+ },
5840
+ {
5841
+ pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,
5842
+ alias: 'return-type',
5843
+ greedy: true,
5844
+ lookbehind: true
5845
+ },
5846
+ {
5847
+ pattern: /\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,
5848
+ alias: 'type-declaration',
5849
+ greedy: true
5850
+ },
5851
+ {
5852
+ pattern: /(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,
5853
+ alias: 'type-declaration',
5854
+ greedy: true,
5855
+ lookbehind: true
5856
+ },
5857
+ {
5858
+ pattern: /\b(?:parent|self|static)(?=\s*::)/i,
5859
+ alias: 'static-context',
5860
+ greedy: true
5861
+ },
5862
+ {
5863
+ // yield from
5864
+ pattern: /(\byield\s+)from\b/i,
5865
+ lookbehind: true
5866
+ },
5867
+ // `class` is always a keyword unlike other keywords
5868
+ /\bclass\b/i,
5869
+ {
5870
+ // https://www.php.net/manual/en/reserved.keywords.php
5871
+ //
5872
+ // keywords cannot be preceded by "->"
5873
+ // the complex lookbehind means `(?<!(?:->|::)\s*)`
5874
+ pattern: /((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,
5875
+ lookbehind: true
5876
+ }
5877
+ ],
5878
+ 'argument-name': {
5879
+ pattern: /([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,
5880
+ lookbehind: true
5881
+ },
5882
+ 'class-name': [
5883
+ {
5884
+ pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,
5885
+ greedy: true,
5886
+ lookbehind: true
5887
+ },
5888
+ {
5889
+ pattern: /(\|\s*)\b[a-z_]\w*(?!\\)\b/i,
5890
+ greedy: true,
5891
+ lookbehind: true
5892
+ },
5893
+ {
5894
+ pattern: /\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,
5895
+ greedy: true
5896
+ },
5897
+ {
5898
+ pattern: /(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,
5899
+ alias: 'class-name-fully-qualified',
5900
+ greedy: true,
5901
+ lookbehind: true,
5902
+ inside: {
5903
+ 'punctuation': /\\/
5904
+ }
5905
+ },
5906
+ {
5907
+ pattern: /(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,
5908
+ alias: 'class-name-fully-qualified',
5909
+ greedy: true,
5910
+ inside: {
5911
+ 'punctuation': /\\/
5912
+ }
5913
+ },
5914
+ {
5915
+ pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
5916
+ alias: 'class-name-fully-qualified',
5917
+ greedy: true,
5918
+ lookbehind: true,
5919
+ inside: {
5920
+ 'punctuation': /\\/
5921
+ }
5922
+ },
5923
+ {
5924
+ pattern: /\b[a-z_]\w*(?=\s*\$)/i,
5925
+ alias: 'type-declaration',
5926
+ greedy: true
5927
+ },
5928
+ {
5929
+ pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
5930
+ alias: ['class-name-fully-qualified', 'type-declaration'],
5931
+ greedy: true,
5932
+ inside: {
5933
+ 'punctuation': /\\/
5934
+ }
5935
+ },
5936
+ {
5937
+ pattern: /\b[a-z_]\w*(?=\s*::)/i,
5938
+ alias: 'static-context',
5939
+ greedy: true
5940
+ },
5941
+ {
5942
+ pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,
5943
+ alias: ['class-name-fully-qualified', 'static-context'],
5944
+ greedy: true,
5945
+ inside: {
5946
+ 'punctuation': /\\/
5947
+ }
5948
+ },
5949
+ {
5950
+ pattern: /([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,
5951
+ alias: 'type-hint',
5952
+ greedy: true,
5953
+ lookbehind: true
5954
+ },
5955
+ {
5956
+ pattern: /([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
5957
+ alias: ['class-name-fully-qualified', 'type-hint'],
5958
+ greedy: true,
5959
+ lookbehind: true,
5960
+ inside: {
5961
+ 'punctuation': /\\/
5962
+ }
5963
+ },
5964
+ {
5965
+ pattern: /(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,
5966
+ alias: 'return-type',
5967
+ greedy: true,
5968
+ lookbehind: true
5969
+ },
5970
+ {
5971
+ pattern: /(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
5972
+ alias: ['class-name-fully-qualified', 'return-type'],
5973
+ greedy: true,
5974
+ lookbehind: true,
5975
+ inside: {
5976
+ 'punctuation': /\\/
5977
+ }
5978
+ }
5979
+ ],
5980
+ 'constant': constant,
5981
+ 'function': {
5982
+ pattern: /(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,
5983
+ lookbehind: true,
5984
+ inside: {
5985
+ 'punctuation': /\\/
5986
+ }
5987
+ },
5988
+ 'property': {
5989
+ pattern: /(->\s*)\w+/,
5990
+ lookbehind: true
5991
+ },
5992
+ 'number': number,
5993
+ 'operator': operator,
5994
+ 'punctuation': punctuation
5995
+ };
5996
+
5997
+ var string_interpolation = {
5998
+ pattern: /\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,
5999
+ lookbehind: true,
6000
+ inside: Prism.languages.php
6001
+ };
6002
+
6003
+ var string = [
6004
+ {
6005
+ pattern: /<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,
6006
+ alias: 'nowdoc-string',
6007
+ greedy: true,
6008
+ inside: {
6009
+ 'delimiter': {
6010
+ pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
6011
+ alias: 'symbol',
6012
+ inside: {
6013
+ 'punctuation': /^<<<'?|[';]$/
6014
+ }
6015
+ }
6016
+ }
6017
+ },
6018
+ {
6019
+ pattern: /<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,
6020
+ alias: 'heredoc-string',
6021
+ greedy: true,
6022
+ inside: {
6023
+ 'delimiter': {
6024
+ pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
6025
+ alias: 'symbol',
6026
+ inside: {
6027
+ 'punctuation': /^<<<"?|[";]$/
6028
+ }
6029
+ },
6030
+ 'interpolation': string_interpolation
6031
+ }
6032
+ },
6033
+ {
6034
+ pattern: /`(?:\\[\s\S]|[^\\`])*`/,
6035
+ alias: 'backtick-quoted-string',
6036
+ greedy: true
6037
+ },
6038
+ {
6039
+ pattern: /'(?:\\[\s\S]|[^\\'])*'/,
6040
+ alias: 'single-quoted-string',
6041
+ greedy: true
6042
+ },
6043
+ {
6044
+ pattern: /"(?:\\[\s\S]|[^\\"])*"/,
6045
+ alias: 'double-quoted-string',
6046
+ greedy: true,
6047
+ inside: {
6048
+ 'interpolation': string_interpolation
6049
+ }
6050
+ }
6051
+ ];
6052
+
6053
+ Prism.languages.insertBefore('php', 'variable', {
6054
+ 'string': string,
6055
+ 'attribute': {
6056
+ pattern: /#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,
6057
+ greedy: true,
6058
+ inside: {
6059
+ 'attribute-content': {
6060
+ pattern: /^(#\[)[\s\S]+(?=\]$)/,
6061
+ lookbehind: true,
6062
+ // inside can appear subset of php
6063
+ inside: {
6064
+ 'comment': comment,
6065
+ 'string': string,
6066
+ 'attribute-class-name': [
6067
+ {
6068
+ pattern: /([^:]|^)\b[a-z_]\w*(?!\\)\b/i,
6069
+ alias: 'class-name',
6070
+ greedy: true,
6071
+ lookbehind: true
6072
+ },
6073
+ {
6074
+ pattern: /([^:]|^)(?:\\?\b[a-z_]\w*)+/i,
6075
+ alias: [
6076
+ 'class-name',
6077
+ 'class-name-fully-qualified'
6078
+ ],
6079
+ greedy: true,
6080
+ lookbehind: true,
6081
+ inside: {
6082
+ 'punctuation': /\\/
6083
+ }
6084
+ }
6085
+ ],
6086
+ 'constant': constant,
6087
+ 'number': number,
6088
+ 'operator': operator,
6089
+ 'punctuation': punctuation
6090
+ }
6091
+ },
6092
+ 'delimiter': {
6093
+ pattern: /^#\[|\]$/,
6094
+ alias: 'punctuation'
6095
+ }
6096
+ }
6097
+ },
6098
+ });
6099
+
6100
+ Prism.hooks.add('before-tokenize', function (env) {
6101
+ if (!/<\?/.test(env.code)) {
6102
+ return;
6103
+ }
6104
+
6105
+ var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;
6106
+ Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
6107
+ });
6108
+
6109
+ Prism.hooks.add('after-tokenize', function (env) {
6110
+ Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
6111
+ });
6112
+
6113
+ }(Prism));
6114
+
6115
+ Prism.languages.go = Prism.languages.extend('clike', {
6116
+ 'string': {
6117
+ pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,
6118
+ lookbehind: true,
6119
+ greedy: true
6120
+ },
6121
+ 'keyword': /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
6122
+ 'boolean': /\b(?:_|false|iota|nil|true)\b/,
6123
+ 'number': [
6124
+ // binary and octal integers
6125
+ /\b0(?:b[01_]+|o[0-7_]+)i?\b/i,
6126
+ // hexadecimal integers and floats
6127
+ /\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,
6128
+ // decimal integers and floats
6129
+ /(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i
6130
+ ],
6131
+ 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
6132
+ 'builtin': /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/
6133
+ });
6134
+
6135
+ Prism.languages.insertBefore('go', 'string', {
6136
+ 'char': {
6137
+ pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/,
6138
+ greedy: true
6139
+ }
6140
+ });
6141
+
6142
+ delete Prism.languages.go['class-name'];
6143
+
6144
+ (function (Prism) {
6145
+ // $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|'
6146
+ // + LC_ALL, RANDOM, REPLY, SECONDS.
6147
+ // + make sure PS1..4 are here as they are not always set,
6148
+ // - some useless things.
6149
+ var envVars = '\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b';
6150
+
6151
+ var commandAfterHeredoc = {
6152
+ pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
6153
+ lookbehind: true,
6154
+ alias: 'punctuation', // this looks reasonably well in all themes
6155
+ inside: null // see below
6156
+ };
6157
+
6158
+ var insideString = {
6159
+ 'bash': commandAfterHeredoc,
6160
+ 'environment': {
6161
+ pattern: RegExp('\\$' + envVars),
6162
+ alias: 'constant'
6163
+ },
6164
+ 'variable': [
6165
+ // [0]: Arithmetic Environment
6166
+ {
6167
+ pattern: /\$?\(\([\s\S]+?\)\)/,
6168
+ greedy: true,
6169
+ inside: {
6170
+ // If there is a $ sign at the beginning highlight $(( and )) as variable
6171
+ 'variable': [
6172
+ {
6173
+ pattern: /(^\$\(\([\s\S]+)\)\)/,
6174
+ lookbehind: true
6175
+ },
6176
+ /^\$\(\(/
6177
+ ],
6178
+ 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
6179
+ // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
6180
+ 'operator': /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
6181
+ // If there is no $ sign at the beginning highlight (( and )) as punctuation
6182
+ 'punctuation': /\(\(?|\)\)?|,|;/
6183
+ }
6184
+ },
6185
+ // [1]: Command Substitution
6186
+ {
6187
+ pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
6188
+ greedy: true,
6189
+ inside: {
6190
+ 'variable': /^\$\(|^`|\)$|`$/
6191
+ }
6192
+ },
6193
+ // [2]: Brace expansion
6194
+ {
6195
+ pattern: /\$\{[^}]+\}/,
6196
+ greedy: true,
6197
+ inside: {
6198
+ 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
6199
+ 'punctuation': /[\[\]]/,
6200
+ 'environment': {
6201
+ pattern: RegExp('(\\{)' + envVars),
6202
+ lookbehind: true,
6203
+ alias: 'constant'
6204
+ }
6205
+ }
6206
+ },
6207
+ /\$(?:\w+|[#?*!@$])/
6208
+ ],
6209
+ // Escape sequences from echo and printf's manuals, and escaped quotes.
6210
+ 'entity': /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
6211
+ };
6212
+
6213
+ Prism.languages.bash = {
6214
+ 'shebang': {
6215
+ pattern: /^#!\s*\/.*/,
6216
+ alias: 'important'
6217
+ },
6218
+ 'comment': {
6219
+ pattern: /(^|[^"{\\$])#.*/,
6220
+ lookbehind: true
6221
+ },
6222
+ 'function-name': [
6223
+ // a) function foo {
6224
+ // b) foo() {
6225
+ // c) function foo() {
6226
+ // but not “foo {”
6227
+ {
6228
+ // a) and c)
6229
+ pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
6230
+ lookbehind: true,
6231
+ alias: 'function'
6232
+ },
6233
+ {
6234
+ // b)
6235
+ pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
6236
+ alias: 'function'
6237
+ }
6238
+ ],
6239
+ // Highlight variable names as variables in for and select beginnings.
6240
+ 'for-or-select': {
6241
+ pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
6242
+ alias: 'variable',
6243
+ lookbehind: true
6244
+ },
6245
+ // Highlight variable names as variables in the left-hand part
6246
+ // of assignments (“=” and “+=”).
6247
+ 'assign-left': {
6248
+ pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
6249
+ inside: {
6250
+ 'environment': {
6251
+ pattern: RegExp('(^|[\\s;|&]|[<>]\\()' + envVars),
6252
+ lookbehind: true,
6253
+ alias: 'constant'
6254
+ }
6255
+ },
6256
+ alias: 'variable',
6257
+ lookbehind: true
6258
+ },
6259
+ // Highlight parameter names as variables
6260
+ 'parameter': {
6261
+ pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
6262
+ alias: 'variable',
6263
+ lookbehind: true
6264
+ },
6265
+ 'string': [
6266
+ // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
6267
+ {
6268
+ pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
6269
+ lookbehind: true,
6270
+ greedy: true,
6271
+ inside: insideString
6272
+ },
6273
+ // Here-document with quotes around the tag
6274
+ // → No expansion (so no “inside”).
6275
+ {
6276
+ pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
6277
+ lookbehind: true,
6278
+ greedy: true,
6279
+ inside: {
6280
+ 'bash': commandAfterHeredoc
6281
+ }
6282
+ },
6283
+ // “Normal” string
6284
+ {
6285
+ // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
6286
+ pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
6287
+ lookbehind: true,
6288
+ greedy: true,
6289
+ inside: insideString
6290
+ },
6291
+ {
6292
+ // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
6293
+ pattern: /(^|[^$\\])'[^']*'/,
6294
+ lookbehind: true,
6295
+ greedy: true
6296
+ },
6297
+ {
6298
+ // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
6299
+ pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
6300
+ greedy: true,
6301
+ inside: {
6302
+ 'entity': insideString.entity
6303
+ }
6304
+ }
6305
+ ],
6306
+ 'environment': {
6307
+ pattern: RegExp('\\$?' + envVars),
6308
+ alias: 'constant'
6309
+ },
6310
+ 'variable': insideString.variable,
6311
+ 'function': {
6312
+ pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
6313
+ lookbehind: true
6314
+ },
6315
+ 'keyword': {
6316
+ pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
6317
+ lookbehind: true
6318
+ },
6319
+ // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
6320
+ 'builtin': {
6321
+ pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
6322
+ lookbehind: true,
6323
+ // Alias added to make those easier to distinguish from strings.
6324
+ alias: 'class-name'
6325
+ },
6326
+ 'boolean': {
6327
+ pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
6328
+ lookbehind: true
6329
+ },
6330
+ 'file-descriptor': {
6331
+ pattern: /\B&\d\b/,
6332
+ alias: 'important'
6333
+ },
6334
+ 'operator': {
6335
+ // Lots of redirections here, but not just that.
6336
+ pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
6337
+ inside: {
6338
+ 'file-descriptor': {
6339
+ pattern: /^\d/,
6340
+ alias: 'important'
6341
+ }
6342
+ }
6343
+ },
6344
+ 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
6345
+ 'number': {
6346
+ pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
6347
+ lookbehind: true
6348
+ }
6349
+ };
6350
+
6351
+ commandAfterHeredoc.inside = Prism.languages.bash;
6352
+
6353
+ /* Patterns in command substitution. */
6354
+ var toBeCopied = [
6355
+ 'comment',
6356
+ 'function-name',
6357
+ 'for-or-select',
6358
+ 'assign-left',
6359
+ 'parameter',
6360
+ 'string',
6361
+ 'environment',
6362
+ 'function',
6363
+ 'keyword',
6364
+ 'builtin',
6365
+ 'boolean',
6366
+ 'file-descriptor',
6367
+ 'operator',
6368
+ 'punctuation',
6369
+ 'number'
6370
+ ];
6371
+ var inside = insideString.variable[1].inside;
6372
+ for (var i = 0; i < toBeCopied.length; i++) {
6373
+ inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]];
6374
+ }
6375
+
6376
+ Prism.languages.sh = Prism.languages.bash;
6377
+ Prism.languages.shell = Prism.languages.bash;
6378
+ }(Prism));
6379
+
6380
+ // https://www.json.org/json-en.html
6381
+ Prism.languages.json = {
6382
+ 'property': {
6383
+ pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
6384
+ lookbehind: true,
6385
+ greedy: true
6386
+ },
6387
+ 'string': {
6388
+ pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
6389
+ lookbehind: true,
6390
+ greedy: true
6391
+ },
6392
+ 'comment': {
6393
+ pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
6394
+ greedy: true
6395
+ },
6396
+ 'number': /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
6397
+ 'punctuation': /[{}[\],]/,
6398
+ 'operator': /:/,
6399
+ 'boolean': /\b(?:false|true)\b/,
6400
+ 'null': {
6401
+ pattern: /\bnull\b/,
6402
+ alias: 'keyword'
6403
+ }
6404
+ };
6405
+
6406
+ Prism.languages.webmanifest = Prism.languages.json;
5522
6407
 
5523
- <button class="lexxy-editor__toolbar-button" type="button" name="heading" data-command="rotateHeadingFormat" title="Heading">
5524
- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M15.322 5.315H9.64V22H5.684V5.315H0v-3.31h15.322v3.31z"/><path d="M23.957 11.79H19.92V22h-3.402V11.79H12.48V9.137h11.477v2.653z"/></svg>
5525
- </button>
6408
+ (function (Prism) {
5526
6409
 
5527
- <button class="lexxy-editor__toolbar-button" type="button" name="code" data-command="insertCodeBlock" title="Code">
5528
- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M10.121 6l-6 6 6 6-2.12 2.121-7.061-7.06a1.5 1.5 0 010-2.121L8 3.879 10.121 6zM23.06 10.94a1.5 1.5 0 010 2.12L16 20.121 13.88 18l6-6-6-6L16 3.879l7.06 7.06z"/></svg>
5529
- </button>
6410
+ Prism.languages.diff = {
6411
+ 'coord': [
6412
+ // Match all kinds of coord lines (prefixed by "+++", "---" or "***").
6413
+ /^(?:\*{3}|-{3}|\+{3}).*$/m,
6414
+ // Match "@@ ... @@" coord lines in unified diff.
6415
+ /^@@.*@@$/m,
6416
+ // Match coord lines in normal diff (starts with a number).
6417
+ /^\d.*$/m
6418
+ ]
5530
6419
 
5531
- <button class="lexxy-editor__toolbar-button" type="button" name="unordered-list" data-command="insertUnorderedList" title="Bullet list">
5532
- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M5 5a2 2 0 11-4 0 2 2 0 014 0zM5 12a2 2 0 11-4 0 2 2 0 014 0zM5 19a2 2 0 11-4 0 2 2 0 014 0zM7 5.25C7 4.56 7.56 4 8.25 4h13.5a1.25 1.25 0 110 2.5H8.25C7.56 6.5 7 5.94 7 5.25zM7 12.25c0-.69.56-1.25 1.25-1.25h13.5a1.25 1.25 0 110 2.5H8.25c-.69 0-1.25-.56-1.25-1.25zM7 19.25c0-.69.56-1.25 1.25-1.25h13.5a1.25 1.25 0 110 2.5H8.25c-.69 0-1.25-.56-1.25-1.25z"/></svg>
5533
- </button>
6420
+ // deleted, inserted, unchanged, diff
6421
+ };
5534
6422
 
5535
- <button class="lexxy-editor__toolbar-button" type="button" name="ordered-list" data-command="insertOrderedList" title="Numbered list">
5536
- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.25C7 4.56 7.56 4 8.25 4h13.5a1.25 1.25 0 110 2.5H8.25C7.56 6.5 7 5.94 7 5.25zM7 12.25c0-.69.56-1.25 1.25-1.25h13.5a1.25 1.25 0 110 2.5H8.25c-.69 0-1.25-.56-1.25-1.25zM7 19.25c0-.69.56-1.25 1.25-1.25h13.5a1.25 1.25 0 110 2.5H8.25c-.69 0-1.25-.56-1.25-1.25zM4.438 8H3.39V3.684H3.34c-.133.093-.267.188-.402.285l-.407.289a129.5 129.5 0 00-.402.285v-.969l.633-.453c.21-.15.42-.302.629-.453h1.046V8zM2.672 11.258h-1v-.051c0-.206.036-.405.11-.598.075-.195.188-.37.34-.527.15-.156.339-.281.566-.375.229-.094.498-.14.808-.14.367 0 .688.065.961.195s.484.308.633.535c.15.224.226.478.226.762 0 .244-.046.463-.14.656-.091.19-.209.368-.352.535-.14.164-.289.332-.445.504L3.168 14.09v.05h2.238V15H1.723v-.656l1.949-2.102c.096-.101.19-.207.281-.316.091-.112.167-.232.227-.36a.953.953 0 00.09-.41.712.712 0 00-.387-.648.845.845 0 00-.41-.098.81.81 0 00-.43.11.75.75 0 00-.277.293.824.824 0 00-.094.386V11.258zM2.852 19.66v-.812h.562a.917.917 0 00.43-.098.742.742 0 00.293-.266.673.673 0 00.101-.379.654.654 0 00-.234-.523.87.87 0 00-.59-.2.987.987 0 00-.336.055.837.837 0 00-.258.149.712.712 0 00-.172.215.66.66 0 00-.066.25h-.98c.007-.209.053-.403.136-.582.084-.18.203-.336.36-.469.156-.135.346-.24.57-.316.227-.076.486-.115.777-.118a2.33 2.33 0 01.965.176c.271.12.48.285.63.496.15.209.227.448.23.719a1.11 1.11 0 01-.16.637 1.28 1.28 0 01-.825.586v.054c.162.016.33.07.504.164.177.094.328.232.453.415.125.18.189.411.192.695a1.37 1.37 0 01-.157.676c-.104.197-.25.365-.437.503-.188.136-.404.24-.649.313-.242.07-.5.105-.777.105-.401 0-.743-.067-1.027-.203a1.608 1.608 0 01-.649-.547 1.46 1.46 0 01-.238-.75h.969c.01.128.057.243.14.344a.885.885 0 00.332.238c.141.058.3.088.477.09.195 0 .366-.034.512-.101a.798.798 0 00.336-.29.744.744 0 00.117-.425.74.74 0 00-.446-.695 1.082 1.082 0 00-.496-.106h-.59z"/></svg>
5537
- </button>
6423
+ /**
6424
+ * A map from the name of a block to its line prefix.
6425
+ *
6426
+ * @type {Object<string, string>}
6427
+ */
6428
+ var PREFIXES = {
6429
+ 'deleted-sign': '-',
6430
+ 'deleted-arrow': '<',
6431
+ 'inserted-sign': '+',
6432
+ 'inserted-arrow': '>',
6433
+ 'unchanged': ' ',
6434
+ 'diff': '!',
6435
+ };
5538
6436
 
5539
- <button class="lexxy-editor__toolbar-button" type="button" name="upload" data-command="uploadAttachments" title="Upload file">
5540
- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M16 8a2 2 0 110 4 2 2 0 010-4z""/><path d="M22 2a1 1 0 011 1v18a1 1 0 01-1 1H2a1 1 0 01-1-1V3a1 1 0 011-1h20zM3 18.714L9 11l5.25 6.75L17 15l4 4V4H3v14.714z"/></svg>
5541
- </button>
6437
+ // add a token for each prefix
6438
+ Object.keys(PREFIXES).forEach(function (name) {
6439
+ var prefix = PREFIXES[name];
5542
6440
 
5543
- <button class="lexxy-editor__toolbar-button" type="button" name="divider" data-command="insertHorizontalDivider" title="Insert a divider">
5544
- <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 12C0 11.4477 0.447715 11 1 11H23C23.5523 11 24 11.4477 24 12C24 12.5523 23.5523 13 23 13H1C0.447716 13 0 12.5523 0 12Z"/><path d="M4 5C4 3.89543 4.89543 3 6 3H18C19.1046 3 20 3.89543 20 5C20 6.10457 19.1046 7 18 7H6C4.89543 7 4 6.10457 4 5Z"/><path d="M4 19C4 17.8954 4.89543 17 6 17H18C19.1046 17 20 17.8954 20 19C20 20.1046 19.1046 21 18 21H6C4.89543 21 4 20.1046 4 19Z"/></svg>
5545
- </button>
5546
-
5547
- <div class="lexxy-editor__toolbar-spacer" role="separator"></div>
5548
-
5549
- <button class="lexxy-editor__toolbar-button" type="button" name="undo" data-command="undo" title="Undo" data-hotkey="cmd+z ctrl+z">
5550
- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M5.64648 8.26531C7.93911 6.56386 10.7827 5.77629 13.624 6.05535C16.4655 6.33452 19.1018 7.66079 21.0195 9.77605C22.5839 11.5016 23.5799 13.6516 23.8936 15.9352C24.0115 16.7939 23.2974 17.4997 22.4307 17.4997C21.5641 17.4997 20.8766 16.7915 20.7148 15.9401C20.4295 14.4379 19.7348 13.0321 18.6943 11.8844C17.3 10.3464 15.3835 9.38139 13.3174 9.17839C11.2514 8.97546 9.18359 9.54856 7.5166 10.7858C6.38259 11.6275 5.48981 12.7361 4.90723 13.9997H8.5C9.3283 13.9997 9.99979 14.6714 10 15.4997C10 16.3281 9.32843 16.9997 8.5 16.9997H1.5C0.671573 16.9997 0 16.3281 0 15.4997V8.49968C0.000213656 7.67144 0.671705 6.99968 1.5 6.99968C2.3283 6.99968 2.99979 7.67144 3 8.49968V11.0212C3.7166 9.9704 4.60793 9.03613 5.64648 8.26531Z"/></svg>
5551
- </button>
6441
+ var alias = [];
6442
+ if (!/^\w+$/.test(name)) { // "deleted-sign" -> "deleted"
6443
+ alias.push(/\w+/.exec(name)[0]);
6444
+ }
6445
+ if (name === 'diff') {
6446
+ alias.push('bold');
6447
+ }
5552
6448
 
5553
- <button class="lexxy-editor__toolbar-button" type="button" name="redo" data-command="redo" title="Redo" data-hotkey="cmd+shift+z ctrl+shift+z ctrl+y">
5554
- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M18.2599 8.26531C15.9672 6.56386 13.1237 5.77629 10.2823 6.05535C7.4408 6.33452 4.80455 7.66079 2.88681 9.77605C1.32245 11.5016 0.326407 13.6516 0.0127834 15.9352C-0.105117 16.7939 0.608975 17.4997 1.47567 17.4997C2.34228 17.4997 3.02969 16.7915 3.19149 15.9401C3.47682 14.4379 4.17156 13.0321 5.212 11.8844C6.60637 10.3464 8.52287 9.38139 10.589 9.17839C12.655 8.97546 14.7227 9.54856 16.3897 10.7858C17.5237 11.6275 18.4165 12.7361 18.9991 13.9997H15.4063C14.578 13.9997 13.9066 14.6714 13.9063 15.4997C13.9063 16.3281 14.5779 16.9997 15.4063 16.9997H22.4063C23.2348 16.9997 23.9063 16.3281 23.9063 15.4997V8.49968C23.9061 7.67144 23.2346 6.99968 22.4063 6.99968C21.578 6.99968 20.9066 7.67144 20.9063 8.49968V11.0212C20.1897 9.9704 19.2984 9.03613 18.2599 8.26531Z"/></svg>
5555
- </button>
6449
+ Prism.languages.diff[name] = {
6450
+ pattern: RegExp('^(?:[' + prefix + '].*(?:\r\n?|\n|(?![\\s\\S])))+', 'm'),
6451
+ alias: alias,
6452
+ inside: {
6453
+ 'line': {
6454
+ pattern: /(.)(?=[\s\S]).*(?:\r\n?|\n)?/,
6455
+ lookbehind: true
6456
+ },
6457
+ 'prefix': {
6458
+ pattern: /[\s\S]/,
6459
+ alias: /\w+/.exec(name)[0]
6460
+ }
6461
+ }
6462
+ };
5556
6463
 
5557
- <details class="lexxy-editor__toolbar-overflow">
5558
- <summary class="lexxy-editor__toolbar-button" aria-label="Show more toolbar buttons">•••</summary>
5559
- <div class="lexxy-editor__toolbar-overflow-menu" aria-label="More toolbar buttons"></div>
5560
- </details>
5561
- `
5562
- }
5563
- }
6464
+ });
5564
6465
 
5565
- customElements.define("lexxy-toolbar", LexicalToolbarElement);
6466
+ // make prefixes available to Diff plugin
6467
+ Object.defineProperty(Prism.languages.diff, 'PREFIXES', {
6468
+ value: PREFIXES
6469
+ });
6470
+
6471
+ }(Prism));
5566
6472
 
5567
6473
  /**
5568
6474
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -5598,6 +6504,7 @@ var theme = {
5598
6504
  }
5599
6505
  },
5600
6506
  codeHighlight: {
6507
+ addition: "code-token__selector",
5601
6508
  atrule: "code-token__attr",
5602
6509
  attr: "code-token__attr",
5603
6510
  "attr-name": "code-token__attr",
@@ -5612,24 +6519,30 @@ var theme = {
5612
6519
  color: "code-token__property",
5613
6520
  comment: "code-token__comment",
5614
6521
  constant: "code-token__property",
5615
- coord: "code-token__property",
6522
+ coord: "code-token__comment",
5616
6523
  decorator: "code-token__function",
5617
- deleted: "code-token__property",
6524
+ deleted: "code-token__operator",
6525
+ deletion: "code-token__operator",
6526
+ directive: "code-token__attr",
6527
+ "directive-hash": "code-token__property",
5618
6528
  doctype: "code-token__comment",
5619
6529
  entity: "code-token__operator",
5620
6530
  function: "code-token__function",
5621
6531
  hexcode: "code-token__property",
5622
- important: "code-token__variable",
6532
+ important: "code-token__function",
5623
6533
  inserted: "code-token__selector",
5624
6534
  italic: "code-token__comment",
5625
6535
  keyword: "code-token__attr",
6536
+ line: "code-token__selector",
5626
6537
  namespace: "code-token__variable",
5627
6538
  number: "code-token__property",
6539
+ macro: "code-token__function",
5628
6540
  operator: "code-token__operator",
5629
6541
  parameter: "code-token__variable",
5630
6542
  prolog: "code-token__comment",
5631
6543
  property: "code-token__property",
5632
6544
  punctuation: "code-token__punctuation",
6545
+ "raw-string": "code-token__operator",
5633
6546
  regex: "code-token__variable",
5634
6547
  script: "code-token__function",
5635
6548
  selector: "code-token__selector",
@@ -5638,6 +6551,7 @@ var theme = {
5638
6551
  symbol: "code-token__property",
5639
6552
  tag: "code-token__property",
5640
6553
  title: "code-token__function",
6554
+ "type-definition": "code-token__function",
5641
6555
  url: "code-token__operator",
5642
6556
  variable: "code-token__variable",
5643
6557
  }
@@ -8418,27 +9332,37 @@ class Clipboard {
8418
9332
  class Highlighter {
8419
9333
  constructor(editorElement) {
8420
9334
  this.editor = editorElement.editor;
9335
+
9336
+ this.#registerHighlightTransform();
8421
9337
  }
8422
9338
 
8423
9339
  toggle(styles) {
8424
9340
  this.editor.update(() => {
8425
9341
  this.#toggleSelectionStyles(styles);
8426
- j$2(node => this.#syncHighlightWithStyle(node));
8427
9342
  });
8428
9343
  }
8429
9344
 
8430
9345
  remove() {
8431
- this.toggle({ "color": undefined, "background-color": undefined });
9346
+ this.toggle({ "color": null, "background-color": null });
9347
+ }
9348
+
9349
+ #registerHighlightTransform() {
9350
+ return this.editor.registerNodeTransform(Xn, (textNode) => {
9351
+ this.#syncHighlightWithStyle(textNode);
9352
+ })
8432
9353
  }
8433
9354
 
8434
9355
  #toggleSelectionStyles(styles) {
8435
9356
  const selection = Lr();
9357
+ if (!yr(selection)) return
8436
9358
 
9359
+ const patch = {};
8437
9360
  for (const property in styles) {
8438
9361
  const oldValue = le$1(selection, property);
8439
- const patch = { [property]: this.#toggleOrReplace(oldValue, styles[property]) };
8440
- U$5(selection, patch);
9362
+ patch[property] = this.#toggleOrReplace(oldValue, styles[property]);
8441
9363
  }
9364
+
9365
+ U$5(selection, patch);
8442
9366
  }
8443
9367
 
8444
9368
  #toggleOrReplace(oldValue, newValue) {
@@ -8446,15 +9370,10 @@ class Highlighter {
8446
9370
  }
8447
9371
 
8448
9372
  #syncHighlightWithStyle(node) {
8449
- if (this.#hasHighlightStyles(node) !== node.hasFormat("highlight")) {
9373
+ if (hasHighlightStyles(node.getStyle()) !== node.hasFormat("highlight")) {
8450
9374
  node.toggleFormat("highlight");
8451
9375
  }
8452
9376
  }
8453
-
8454
- #hasHighlightStyles(node) {
8455
- const styles = b$3(node.getStyle());
8456
- return !!(styles.color || styles["background-color"])
8457
- }
8458
9377
  }
8459
9378
 
8460
9379
  class HighlightNode extends Xn {
@@ -9107,6 +10026,11 @@ customElements.define("lexxy-link-dialog", LinkDialog);
9107
10026
  const APPLY_HIGHLIGHT_SELECTOR = "button.lexxy-highlight-button";
9108
10027
  const REMOVE_HIGHLIGHT_SELECTOR = "[data-command='removeHighlight']";
9109
10028
 
10029
+ // Use Symbol instead of null since $getSelectionStyleValueForProperty
10030
+ // responds differently for backward selections if null is the default
10031
+ // see https://github.com/facebook/lexical/issues/8013
10032
+ const NO_STYLE = Symbol("no_style");
10033
+
9110
10034
  class HighlightDialog extends ToolbarDialog {
9111
10035
  connectedCallback() {
9112
10036
  super.connectedCallback();
@@ -9171,16 +10095,16 @@ class HighlightDialog extends ToolbarDialog {
9171
10095
  #updateColorButtonStates(selection) {
9172
10096
  if (!yr(selection)) { return }
9173
10097
 
9174
- // Use null default, so "" indicates mixed highlighting
9175
- const textColor = le$1(selection, "color", null);
9176
- const backgroundColor = le$1(selection, "background-color", null);
10098
+ // Use non-"" default, so "" indicates mixed highlighting
10099
+ const textColor = le$1(selection, "color", NO_STYLE);
10100
+ const backgroundColor = le$1(selection, "background-color", NO_STYLE);
9177
10101
 
9178
10102
  this.#colorButtons.forEach(button => {
9179
10103
  const matchesSelection = button.dataset.value === textColor || button.dataset.value === backgroundColor;
9180
10104
  button.setAttribute("aria-pressed", matchesSelection);
9181
10105
  });
9182
10106
 
9183
- const hasHighlight = textColor !== null || backgroundColor !== null;
10107
+ const hasHighlight = textColor !== NO_STYLE || backgroundColor !== NO_STYLE;
9184
10108
  this.querySelector(REMOVE_HIGHLIGHT_SELECTOR).disabled = !hasHighlight;
9185
10109
  }
9186
10110
 
@@ -9762,6 +10686,11 @@ class CodeLanguagePicker extends HTMLElement {
9762
10686
  const languages = { ...pt };
9763
10687
 
9764
10688
  if (!languages.ruby) languages.ruby = "Ruby";
10689
+ if (!languages.php) languages.php = "PHP";
10690
+ if (!languages.go) languages.go = "Go";
10691
+ if (!languages.bash) languages.bash = "Bash";
10692
+ if (!languages.json) languages.json = "JSON";
10693
+ if (!languages.diff) languages.diff = "Diff";
9765
10694
 
9766
10695
  const sortedEntries = Object.entries(languages)
9767
10696
  .sort(([ , a ], [ , b ]) => a.localeCompare(b));
@@ -9852,196 +10781,6 @@ class CodeLanguagePicker extends HTMLElement {
9852
10781
 
9853
10782
  customElements.define("lexxy-code-language-picker", CodeLanguagePicker);
9854
10783
 
9855
- /**
9856
- * Original by Samuel Flores
9857
- *
9858
- * Adds the following new token classes:
9859
- * constant, builtin, variable, symbol, regex
9860
- */
9861
- (function (Prism) {
9862
- Prism.languages.ruby = Prism.languages.extend('clike', {
9863
- 'comment': {
9864
- pattern: /#.*|^=begin\s[\s\S]*?^=end/m,
9865
- greedy: true
9866
- },
9867
- 'class-name': {
9868
- pattern: /(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,
9869
- lookbehind: true,
9870
- inside: {
9871
- 'punctuation': /[.\\]/
9872
- }
9873
- },
9874
- 'keyword': /\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,
9875
- 'operator': /\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,
9876
- 'punctuation': /[(){}[\].,;]/,
9877
- });
9878
-
9879
- Prism.languages.insertBefore('ruby', 'operator', {
9880
- 'double-colon': {
9881
- pattern: /::/,
9882
- alias: 'punctuation'
9883
- },
9884
- });
9885
-
9886
- var interpolation = {
9887
- pattern: /((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,
9888
- lookbehind: true,
9889
- inside: {
9890
- 'content': {
9891
- pattern: /^(#\{)[\s\S]+(?=\}$)/,
9892
- lookbehind: true,
9893
- inside: Prism.languages.ruby
9894
- },
9895
- 'delimiter': {
9896
- pattern: /^#\{|\}$/,
9897
- alias: 'punctuation'
9898
- }
9899
- }
9900
- };
9901
-
9902
- delete Prism.languages.ruby.function;
9903
-
9904
- var percentExpression = '(?:' + [
9905
- /([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
9906
- /\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,
9907
- /\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,
9908
- /\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,
9909
- /<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source
9910
- ].join('|') + ')';
9911
-
9912
- var symbolName = /(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;
9913
-
9914
- Prism.languages.insertBefore('ruby', 'keyword', {
9915
- 'regex-literal': [
9916
- {
9917
- pattern: RegExp(/%r/.source + percentExpression + /[egimnosux]{0,6}/.source),
9918
- greedy: true,
9919
- inside: {
9920
- 'interpolation': interpolation,
9921
- 'regex': /[\s\S]+/
9922
- }
9923
- },
9924
- {
9925
- pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,
9926
- lookbehind: true,
9927
- greedy: true,
9928
- inside: {
9929
- 'interpolation': interpolation,
9930
- 'regex': /[\s\S]+/
9931
- }
9932
- }
9933
- ],
9934
- 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
9935
- 'symbol': [
9936
- {
9937
- pattern: RegExp(/(^|[^:]):/.source + symbolName),
9938
- lookbehind: true,
9939
- greedy: true
9940
- },
9941
- {
9942
- pattern: RegExp(/([\r\n{(,][ \t]*)/.source + symbolName + /(?=:(?!:))/.source),
9943
- lookbehind: true,
9944
- greedy: true
9945
- },
9946
- ],
9947
- 'method-definition': {
9948
- pattern: /(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,
9949
- lookbehind: true,
9950
- inside: {
9951
- 'function': /\b\w+$/,
9952
- 'keyword': /^self\b/,
9953
- 'class-name': /^\w+/,
9954
- 'punctuation': /\./
9955
- }
9956
- }
9957
- });
9958
-
9959
- Prism.languages.insertBefore('ruby', 'string', {
9960
- 'string-literal': [
9961
- {
9962
- pattern: RegExp(/%[qQiIwWs]?/.source + percentExpression),
9963
- greedy: true,
9964
- inside: {
9965
- 'interpolation': interpolation,
9966
- 'string': /[\s\S]+/
9967
- }
9968
- },
9969
- {
9970
- pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,
9971
- greedy: true,
9972
- inside: {
9973
- 'interpolation': interpolation,
9974
- 'string': /[\s\S]+/
9975
- }
9976
- },
9977
- {
9978
- pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
9979
- alias: 'heredoc-string',
9980
- greedy: true,
9981
- inside: {
9982
- 'delimiter': {
9983
- pattern: /^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,
9984
- inside: {
9985
- 'symbol': /\b\w+/,
9986
- 'punctuation': /^<<[-~]?/
9987
- }
9988
- },
9989
- 'interpolation': interpolation,
9990
- 'string': /[\s\S]+/
9991
- }
9992
- },
9993
- {
9994
- pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
9995
- alias: 'heredoc-string',
9996
- greedy: true,
9997
- inside: {
9998
- 'delimiter': {
9999
- pattern: /^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,
10000
- inside: {
10001
- 'symbol': /\b\w+/,
10002
- 'punctuation': /^<<[-~]?'|'$/,
10003
- }
10004
- },
10005
- 'string': /[\s\S]+/
10006
- }
10007
- }
10008
- ],
10009
- 'command-literal': [
10010
- {
10011
- pattern: RegExp(/%x/.source + percentExpression),
10012
- greedy: true,
10013
- inside: {
10014
- 'interpolation': interpolation,
10015
- 'command': {
10016
- pattern: /[\s\S]+/,
10017
- alias: 'string'
10018
- }
10019
- }
10020
- },
10021
- {
10022
- pattern: /`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,
10023
- greedy: true,
10024
- inside: {
10025
- 'interpolation': interpolation,
10026
- 'command': {
10027
- pattern: /[\s\S]+/,
10028
- alias: 'string'
10029
- }
10030
- }
10031
- }
10032
- ]
10033
- });
10034
-
10035
- delete Prism.languages.ruby.string;
10036
-
10037
- Prism.languages.insertBefore('ruby', 'number', {
10038
- 'builtin': /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,
10039
- 'constant': /\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/
10040
- });
10041
-
10042
- Prism.languages.rb = Prism.languages.ruby;
10043
- }(Prism));
10044
-
10045
10784
  function highlightAll() {
10046
10785
  const elements = document.querySelectorAll("pre[data-language]");
10047
10786