mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-06-26 23:48:42 +00:00
fix work on first load for images inside other nodes
This commit is contained in:
@@ -17,7 +17,17 @@ import {
|
|||||||
crosshairCursor,
|
crosshairCursor,
|
||||||
} from '@codemirror/view';
|
} from '@codemirror/view';
|
||||||
import { EditorState, Compartment, StateEffect, StateField } from '@codemirror/state';
|
import { EditorState, Compartment, StateEffect, StateField } from '@codemirror/state';
|
||||||
import { foldAll as foldAllCmd, unfoldAll as unfoldAllCmd, foldGutter, foldKeymap, foldEffect, foldState, syntaxHighlighting } from '@codemirror/language';
|
import {
|
||||||
|
foldAll as foldAllCmd,
|
||||||
|
unfoldAll as unfoldAllCmd,
|
||||||
|
foldGutter,
|
||||||
|
foldKeymap,
|
||||||
|
foldEffect,
|
||||||
|
foldState,
|
||||||
|
syntaxHighlighting,
|
||||||
|
syntaxTree,
|
||||||
|
ensureSyntaxTree
|
||||||
|
} from '@codemirror/language';
|
||||||
import { defaultKeymap, history, undo, redo, undoDepth, redoDepth } from '@codemirror/commands';
|
import { defaultKeymap, history, undo, redo, undoDepth, redoDepth } from '@codemirror/commands';
|
||||||
import { languages } from '@codemirror/language-data';
|
import { languages } from '@codemirror/language-data';
|
||||||
import { css } from '@codemirror/lang-css';
|
import { css } from '@codemirror/lang-css';
|
||||||
@@ -41,7 +51,6 @@ import { generalKeymap, markdownKeymap } from './extensions/customKeyMaps.js';
|
|||||||
import foldOnPages from './extensions/customFolding.js';
|
import foldOnPages from './extensions/customFolding.js';
|
||||||
import { customHighlightStyle, tokenizeCustomMarkdown, tokenizeCustomCSS } from './extensions/customHighlight.js';
|
import { customHighlightStyle, tokenizeCustomMarkdown, tokenizeCustomCSS } from './extensions/customHighlight.js';
|
||||||
import { legacyCustomHighlightStyle, legacyTokenizeCustomMarkdown } from './extensions/legacyCustomHighlight.js';
|
import { legacyCustomHighlightStyle, legacyTokenizeCustomMarkdown } from './extensions/legacyCustomHighlight.js';
|
||||||
import { syntaxTree } from '@codemirror/language';
|
|
||||||
|
|
||||||
const PAGEBREAK_REGEX_V3 = /^(?=\\page(?:break)?(?: *{[^\n{}]*})?$)/m;
|
const PAGEBREAK_REGEX_V3 = /^(?=\\page(?:break)?(?: *{[^\n{}]*})?$)/m;
|
||||||
|
|
||||||
@@ -90,7 +99,7 @@ const createHighlightPlugin = (renderer, tab)=>{
|
|||||||
let pageCount = 1;
|
let pageCount = 1;
|
||||||
let snippetCount = 0;
|
let snippetCount = 0;
|
||||||
|
|
||||||
const tree = syntaxTree(view.state);
|
const tree = ensureSyntaxTree(view.state, view.state.doc.length, 50) || syntaxTree(view.state);
|
||||||
tree.iterate({
|
tree.iterate({
|
||||||
enter : (node)=>{
|
enter : (node)=>{
|
||||||
if(node.name === 'Image') {
|
if(node.name === 'Image') {
|
||||||
@@ -120,7 +129,6 @@ const createHighlightPlugin = (renderer, tab)=>{
|
|||||||
const to = line.from + tok.to;
|
const to = line.from + tok.to;
|
||||||
|
|
||||||
const attrs = {};
|
const attrs = {};
|
||||||
console.log(tok);
|
|
||||||
// attach URL only for links
|
// attach URL only for links
|
||||||
if(tok.type === 'Image' && tok.url) {
|
if(tok.type === 'Image' && tok.url) {
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,6 @@ export function tokenizeCustomMarkdown(text) {
|
|||||||
let match;
|
let match;
|
||||||
|
|
||||||
while ((match = injectionRegex.exec(lineText)) !== null) {
|
while ((match = injectionRegex.exec(lineText)) !== null) {
|
||||||
console.log(match.indices[1][0]);
|
|
||||||
tokens.push({
|
tokens.push({
|
||||||
line : lineNumber,
|
line : lineNumber,
|
||||||
from : match.indices[1][0],
|
from : match.indices[1][0],
|
||||||
|
|||||||
Reference in New Issue
Block a user