React-ace: تمت إزالة التعليقات التوضيحية اليدوية بواسطة العامل

تم إنشاؤها على ٢ يوليو ٢٠١٨  ·  5تعليقات  ·  مصدر: securingsincity/react-ace

مشكلة

أقوم بعرض مكوِّن react-ace مع annotations مثل هذا:

<ReactAce
  mode={'javascript'}
  // ...
  annotations={[{row: 0, column: 0, type: 'error', text: 'Some error.'}]}
/>

سيظهر التعليق التوضيحي اليدوي لفترة وجيزة ، ثم تتم إزالته بمجرد تشغيل العامل.
تظهر هذه الصورة المتحركة تحديث الصفحة. في كل صفحة يتم تحميلها ، يظهر التعليق التوضيحي ، ولكن تتم إزالته بعد ذلك.
annotation

لقد عطلت العامل باستخدام setOptions={{useWorker: false}} ، لكن هذا أيضًا يعطل التعليقات التوضيحية التي تتم يدويًا.

شكرا!

Documentation

التعليق الأكثر فائدة

بدلاً من استخدام الخاصية annotations ، قمت يدويًا باستخدام setAnnotations .

const Editor = ({ annotations: customAnnotations = [], value }) => {
  const [annotations, setAnnotations] = useState([]);
  const [editor, setEditor] = useState();

  const nextAnnotations = [
    ...annotations.filter(({ custom }) => !custom),  // annotations by worker
    ...customAnnotations.map((annotation) => ({ ...annotation, custom: true })) // flag for exclusion
  ];

  useEffect(() => {
    if (editor) {
      editor.getSession().setAnnotations(nextAnnotations);
    }
  }, [editor, JSON.stringify(nextAnnotations)]);

  return (
    <ReactAce
      mode="html"
      onLoad={setEditor}
      onValidate={setAnnotations}
      setOptions={{ useWorker: true }}
      value={value}
   />
}

ال 5 كومينتر

أشعر أنه يجب أن يكون هناك مجموعتان من التعليقات التوضيحية. التعليقات التوضيحية المضافة يدويًا وتلك التي تم إنشاؤها بواسطة محلل الوضع. أعتقد أنهم يتصادمون حاليًا ويمحوون بعضهم البعض ...

نعم ، هذا ما يحدث. لست متأكدًا مما إذا كان من الممكن وجود تعليقات توضيحية خارج دورة حياة العامل أم لا.

أواجه نفس التحدي.
أريد أن أكون قادرًا على إضافة تعليقات توضيحية مخصصة إلى المحرر ، مع الاحتفاظ بالتعليقات التوضيحية من قبل العامل.

بعد أن قمت بتعيين تعليقاتي التوضيحية المخصصة ، تجاوزت تعليقات العامل التعليقات التوضيحية الخاصة بي.
لقد رأيت اقتراحات لتعطيل العامل مثل ذلك.

setOptions={{useWorker: false}}

يؤدي القيام بذلك إلى تعطيل الشرح التوضيحي للعامل ، ومع ذلك ، فقد اختفت كل عمليات تمييز النص / التركيب. (ليس بالضبط ما أريده)

أريد أن أكون قادرًا على دمج تعليق العامل مع تعليقي المخصص.

هل يمكن لأحد أن يقترح كيفية القيام بذلك؟

مرحبًا ، أنا في موقف مشابه ، غير قادر على إضافة رسائل خطأ مخصصة. اي حل؟

بدلاً من استخدام الخاصية annotations ، قمت يدويًا باستخدام setAnnotations .

const Editor = ({ annotations: customAnnotations = [], value }) => {
  const [annotations, setAnnotations] = useState([]);
  const [editor, setEditor] = useState();

  const nextAnnotations = [
    ...annotations.filter(({ custom }) => !custom),  // annotations by worker
    ...customAnnotations.map((annotation) => ({ ...annotation, custom: true })) // flag for exclusion
  ];

  useEffect(() => {
    if (editor) {
      editor.getSession().setAnnotations(nextAnnotations);
    }
  }, [editor, JSON.stringify(nextAnnotations)]);

  return (
    <ReactAce
      mode="html"
      onLoad={setEditor}
      onValidate={setAnnotations}
      setOptions={{ useWorker: true }}
      value={value}
   />
}
هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات