diff options
Diffstat (limited to 'app/assets/javascripts/vue_shared/components/rich_content_editor/services/renderers/render_utils.js')
-rw-r--r-- | app/assets/javascripts/vue_shared/components/rich_content_editor/services/renderers/render_utils.js | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/app/assets/javascripts/vue_shared/components/rich_content_editor/services/renderers/render_utils.js b/app/assets/javascripts/vue_shared/components/rich_content_editor/services/renderers/render_utils.js deleted file mode 100644 index eff5dbf59f2..00000000000 --- a/app/assets/javascripts/vue_shared/components/rich_content_editor/services/renderers/render_utils.js +++ /dev/null @@ -1,38 +0,0 @@ -import { - buildUneditableBlockTokens, - buildUneditableOpenTokens, - buildUneditableCloseToken, -} from './build_uneditable_token'; - -export const renderUneditableLeaf = (_, { origin }) => buildUneditableBlockTokens(origin()); - -export const renderUneditableBranch = (_, { entering, origin }) => - entering ? buildUneditableOpenTokens(origin()) : buildUneditableCloseToken(); - -const attributeDefinitionRegexp = /(^{:.+}$)/; - -export const isAttributeDefinition = (text) => attributeDefinitionRegexp.test(text); - -const findAttributeDefinition = (node) => { - const literal = - node?.next?.firstChild?.literal || node?.firstChild?.firstChild?.next?.next?.literal; // for headings // for list items; - - return isAttributeDefinition(literal) ? literal : null; -}; - -export const renderWithAttributeDefinitions = (node, { origin }) => { - const attributes = findAttributeDefinition(node); - const token = origin(); - - if (token.type === 'openTag' && attributes) { - Object.assign(token, { - attributes: { - 'data-attribute-definition': attributes, - }, - }); - } - - return token; -}; - -export const willAlwaysRender = () => true; |