-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Поправил определение границ ссылки #1
base: master
Are you sure you want to change the base?
Conversation
Проблема 1: Операции Проблема 2: Операции Решение: Заменил |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вопросики
abbr: 1, acronym: 1, b: 1, bdo: 1, big: 1, cite: 1, code: 1, del: 1, | ||
dfn: 1, em: 1, font: 1, i: 1, ins: 1, label: 1, kbd: 1, q: 1, samp: 1, small: 1, span: 1, strike: 1, | ||
strong: 1, sub: 1, sup: 1, tt: 1, u: 1, 'var': 1 | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ох )
а мы откуда-то позаимствовали этот список, надеюсь? )
может его его в конфиг можно положить?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Реализация функции linkStartEndEvaluator
была inspired by вот этой функцией https://github.com/yandex-ui/ckeditor-dev/blob/master/core/dom/range.js#L525 , которая используется как evaluator
для функций CKEDITOR.dom.range.checkStartOfBlock
и CKEDITOR.dom.range.checkEndOfBlock
.
Список взят отсюда - https://github.com/yandex-ui/ckeditor-dev/blob/master/core/dom/range.js#L517
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
может его его в конфиг можно положить?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в какой? зачем?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ну это же набор инлайн тэгов, похоже на статическую информацию
чтобы можно было реиспользовать
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ты говоришь про проектный конфиг? Тоесть вынести этот список из плагина?
я не думаю, что это нужно будет переиспользовать, так же тут теги не всех inline
элементов
Кажется, имеет смысл выносить, только если это реально где-то понадобится, тоесть, если где-то ещё придётся писать свою функцию определения начала и/или конца блока
plugin.js
Outdated
} | ||
|
||
var isFalseTextNode = node.type == ckeditorNamespace.NODE_TEXT && | ||
!node.hasAscendant('pre') && !ckeditorNamespace.tools.trim(node.getText()).length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
===
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почему именно pre
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
взято отсюда - https://github.com/yandex-ui/ckeditor-dev/blob/master/core/dom/range.js#L543
на сколько я понимаю pre
должно передавать юзер-инпут без изменений даже если это пробелы, поэтому с ним считаются
кажется, замечание про ===
резонно, можно поправить
plugin.js
Outdated
var isFalseTextNode = node.type == ckeditorNamespace.NODE_TEXT && | ||
!node.hasAscendant('pre') && !ckeditorNamespace.tools.trim(node.getText()).length; | ||
|
||
var isFalseInlineBlock = node.type == ckeditorNamespace.NODE_ELEMENT && node.is(inlineChildReqElements); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не хотим оптимизнуть и не вычислять node.is()
, пока это не требуется?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
поправил
plugin.js
Outdated
@@ -14,26 +49,29 @@ | |||
this.editable().on('click', this.plugins.openlink.onClick, this, null, 0); | |||
}, | |||
|
|||
_isInLinkBoundary: function(range, link) { | |||
var prevNode = range.getPreviousNode(linkStartEndEvaluator(CKEDITOR), linkStartEndGuard(link), link); | |||
var nextNode = range.getNextNode(linkStartEndEvaluator(CKEDITOR), linkStartEndGuard(link), link); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
аналогично, можно оптимизнуть и не вычислять nextNode
, если это не нужно
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
поправил
return; | ||
} | ||
|
||
var nativeEvent = event.data.$; | ||
var path = new CKEDITOR.dom.elementPath(new CKEDITOR.dom.element(nativeEvent.target), range.root); | ||
|
||
var link = path.contains('a', true); | ||
if (!link) { | ||
if (!link || this.plugins.openlink._isInLinkBoundary(range, link)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вызов приватного метода? )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
метод принадлежит плагину, внутри которого вызывается
plugin.js
Outdated
!node.hasAscendant('pre') && !ckeditorNamespace.tools.trim(node.getText()).length; | ||
|
||
var isFalseInlineBlock = node.type == ckeditorNamespace.NODE_ELEMENT && node.is(inlineChildReqElements); | ||
// is false inline block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is not inline block
а вообще можно было бы сделать переменную и тогда коммент не нужен
!isInlineBlock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не все inline блоки, нет например img
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
разве img не inline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
да, inline, но тут его специально нет - https://github.com/yandex-ui/ckeditor-dev/blob/master/core/dom/range.js#L549
plugin.js
Outdated
|
||
if (isFalseTextNode || isFalseInlineBlock) { | ||
// is false text node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вот тут совсем не ясно, о чём коммент
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
наверное стоит написать is empty text node
abbr: 1, acronym: 1, b: 1, bdo: 1, big: 1, cite: 1, code: 1, del: 1, | ||
dfn: 1, em: 1, font: 1, i: 1, ins: 1, label: 1, kbd: 1, q: 1, samp: 1, small: 1, span: 1, strike: 1, | ||
strong: 1, sub: 1, sup: 1, tt: 1, u: 1, 'var': 1 | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
может его его в конфиг можно положить?
plugin.js
Outdated
} | ||
|
||
// is false inline block | ||
if (node.type == ckeditorNamespace.NODE_ELEMENT && node.is(inlineChildReqElements)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
проверка "это inline node-а"
а коммент как будто бы про другое ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Имхо коммент выше не нужен, он почти полностью дублирует код.
Может стоит переименовать inlineChildReqElements
во что-то более говорящее (не очень ясно, что значит req
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавил коммент про inlineChildReqElements
- https://github.com/yandex-ui/ckeditor-openlink/pull/1/files#diff-18e559ebd3cc204a52bc1dc3db2adf8bR6
req
- require
plugin.js
Outdated
} | ||
|
||
// is false inline block | ||
if (node.type == ckeditorNamespace.NODE_ELEMENT && node.is(inlineChildReqElements)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Имхо коммент выше не нужен, он почти полностью дублирует код.
Может стоит переименовать inlineChildReqElements
во что-то более говорящее (не очень ясно, что значит req
).
plugin.js
Outdated
if ( | ||
node.type == ckeditorNamespace.NODE_TEXT && !node.hasAscendant('pre') && | ||
!ckeditorNamespace.tools.trim(node.getText()).length | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
имхо тут стоит
- проверку
node.hasAscendant()
делать в самую последнюю очередь (как самую дорогую) - коммент, имхо, стоит переписать на что-то более human readable, сейчас я не очень понимаю вообще что делает
linkStartEndEvaluator
поэтому не могу предложить чего-то конкретного )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Поправил
linkStartEndEvaluator
- это https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_dom_walker.html#property-evaluator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я всё ещё не доволен комментом
он нам говорит "это пустая текстовая нода"
а проверка на непустоту !ckeditorNamespace.tools.trim(node.getText()).length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
эм, если ckeditorNamespace.tools.trim(node.getText()).length = 0
, то !ckeditorNamespace.tools.trim(node.getText()).length = true
))
Убрал функции, приводящии к разбиению текстовых нод
2441dcd
to
7368d2a
Compare
Убрал функции, приводящии к разбиению текстовых нод