Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 0 additions & 135 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"type": "git",
"url": "https://github.com/readmeio/syntax-highlighter.git"
},
"files": [
"dist",
"dist-utils"
],
"main": "dist/index.node.js",
"browser": "dist/index.js",
"exports": {
Expand Down Expand Up @@ -39,7 +43,6 @@
},
"dependencies": {
"codemirror": "^5.54.0",
"codemirror-graphql": "1.3.2",
"prop-types": "^15.7.2",
"react-codemirror2": "^8.0.0"
},
Expand Down
1 change: 0 additions & 1 deletion src/codeMirror/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'codemirror/addon/fold/foldgutter';
import 'codemirror/addon/runmode/runmode';
import 'codemirror/addon/scroll/simplescrollbars';
import 'codemirror/addon/scroll/simplescrollbars.css';
import 'codemirror/mode/meta';
import PropTypes from 'prop-types';
import React from 'react';

Expand Down
2 changes: 1 addition & 1 deletion src/utils/cm-mode-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ require('codemirror/mode/sql/sql');
require('codemirror/mode/swift/swift');
require('codemirror/mode/toml/toml');
require('codemirror/mode/yaml/yaml');
require('codemirror-graphql/mode');
require('./modes/graphql/mode');
require('./modes/solidity');
47 changes: 47 additions & 0 deletions src/utils/modes/graphql/RuleHelpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// oxlint-disable no-param-reassign

/**
* Vendored from `graphql-language-service`'s `esm/parser/RuleHelpers.js`, stripped of its
* TypeScript types.
*
* @license MIT
* @see {@link https://github.com/graphql/graphiql/blob/main/packages/graphql-language-service/src/parser/RuleHelpers.ts}
*/

// These functions help build matching rules for ParseRules.

// An optional rule.
export function opt(ofRule) {
return { ofRule };
}

// A list of another rule.
export function list(ofRule, separator) {
return { ofRule, isList: true, separator };
}

// A constraint described as `but not` in the GraphQL spec.
export function butNot(rule, exclusions) {
const ruleMatch = rule.match;
rule.match = token => {
let check = false;
if (ruleMatch) {
check = ruleMatch(token);
}
return check && exclusions.every(exclusion => exclusion.match && !exclusion.match(token));
};
return rule;
}

// Token of a kind
export function t(kind, style) {
return { style, match: token => token.kind === kind };
}

// Punctuator
export function p(value, style) {
return {
style: style || 'punctuation',
match: token => token.kind === 'Punctuation' && token.value === value,
};
}
Loading