Skip to content

Commit

Permalink
Revert "Add syntax highlighting for placeholders and tags (mozilla#2879
Browse files Browse the repository at this point in the history
…)"

This reverts commit 9220827.
  • Loading branch information
mathjazz committed Jun 20, 2023
1 parent 9220827 commit 658804a
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 87 deletions.
1 change: 0 additions & 1 deletion package-lock.json

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

1 change: 0 additions & 1 deletion translate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"@fluent/langneg": "^0.7.0",
"@fluent/react": "^0.15.1",
"@fluent/syntax": "^0.19.0",
"@lezer/highlight": "^1.1.6",
"@messageformat/fluent": "^0.4.1",
"@reduxjs/toolkit": "^1.6.1",
"classnames": "^2.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { Locale } from '~/context/Locale';
import { useReadonlyEditor } from '~/hooks/useReadonlyEditor';

import { getExtensions, useKeyHandlers } from '../utils/editFieldExtensions';
import { EntityView } from '~/context/EntityView';

export type EditFieldProps = {
index: number;
Expand All @@ -39,14 +38,13 @@ export const EditField = memo(
const { l10n } = useLocalization();
const locale = useContext(Locale);
const readOnly = useReadonlyEditor();
const { entity } = useContext(EntityView);
const { setResultFromInput } = useContext(EditorActions);
const keyHandlers = useKeyHandlers();
const [view, setView] = useState<EditorView | null>(null);

const initView = useCallback((parent: HTMLDivElement | null) => {
if (parent) {
const extensions = getExtensions(entity.format, keyHandlers);
const extensions = getExtensions(keyHandlers);
if (readOnly) {
extensions.push(
EditorState.readOnly.of(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ import {
insertNewlineAndIndent,
standardKeymap,
} from '@codemirror/commands';
import {
HighlightStyle,
StreamLanguage,
bracketMatching,
syntaxHighlighting,
} from '@codemirror/language';
import { bracketMatching } from '@codemirror/language';
import { Extension } from '@codemirror/state';
import { EditorView, keymap } from '@codemirror/view';
import { useContext, useEffect, useRef } from 'react';
Expand All @@ -22,8 +17,6 @@ import {
useHandleEnter,
useHandleEscape,
} from './editFieldShortcuts';
import { fluentMode, commonMode } from './editFieldModes';
import { tags } from '@lezer/highlight';

/**
* Key handlers depend on application state,
Expand Down Expand Up @@ -57,23 +50,13 @@ export function useKeyHandlers() {
return ref;
}

const style = HighlightStyle.define([
{ tag: tags.keyword, color: '#872bff', fontFamily: 'monospace' }, // printf
{ tag: tags.tagName, color: '#3e9682', fontFamily: 'monospace' }, // <...>
{ tag: tags.brace, color: '#872bff', fontWeight: 'bold' }, // {...}
{ tag: tags.name, color: '#872bff' }, // {...}
]);

export const getExtensions = (
format: string,
ref: ReturnType<typeof useKeyHandlers>,
): Extension[] => [
history(),
bracketMatching(),
closeBrackets(),
EditorView.lineWrapping,
StreamLanguage.define<any>(format === 'ftl' ? fluentMode : commonMode),
syntaxHighlighting(style),
keymap.of([
{
key: 'Enter',
Expand Down
64 changes: 0 additions & 64 deletions translate/src/modules/translationform/utils/editFieldModes.ts

This file was deleted.

0 comments on commit 658804a

Please sign in to comment.